Description
I would like to define a field called "meta" on my Document. I read and understood the documentation that states:
Having all metadata accessible through
meta
means that this name is reserved and you shouldn’t have a field called meta on your document. If you, however, need it you can still access the data using the get item (as opposed to attribute) syntax:post['meta']
.
Let's suppose I would like to define following Document:
class MyDocument(elastic.Document):
meta = elastic.Keyword()
I would like to define my mapping, including the field called "meta". How do I do that? I am ripping my hair out of this since I cannot find any way to do that, like meta_ = elastic.Keyword(actual_field_name='meta')
, which would be comparable to other libraries' options (like Pydantic) in DocumentOptions
or anything.
I would be also happy if someone could point out a way how I could add it to the mapping in some other way that does not blow elasticsearch-dsl's internals.
Changing the field name in my schema would be possible, but a hassle and from an ideal point of view, I do not want to.
However, I would also be curious about the decision making in this case. If I understood correctly, we are solely talking about providing an accessor for metadata for "ORM" model instances and what we are discussing here is not at all touching Elasticsearch's internals since it happily accepts a field called meta
. Furthermore, "meta" does not sound like a terrible unlikely name for a document's field. So, if I understand correctly, no one who wants to use elasticsearch-dsl and its declarative persistence can ever declare this field.
Would it not make more sense to provide metadata in some way that has less likelihood of collisions? post.meta_
or post.elastic_meta
or elasticsearch.meta(post)
?