Open
Description
Store.save(document)
with a document serializing _id
field raises because ElasticSearch does not allow _id
being serialized as part of the document body.
While investigating the fix, I've found interesting differences between update
and save
methods
- update uses
__extract_id_from_document
, which- treats
id
as_id
for routing - removes
_id
andid
from the document - does not store
id
outside of_id
field - treats
id
as_id
for routing
- treats
- save uses
__get_id_from_document
, which- treats
id
as_id
for routing - does not remove
_id
orid
from the document - tries to store
id
if it exists - makes the save call fail if document serializes
_id
.
- treats
Having this behaviour forces users to define :id field, instead of being able to define :_id only. Is this a bug or such behaviour is introduced on purpose?
If it's on purpose, I'd like to get some guidance on using :id and :_id field with this gem.