We are currently using Elasticsearch as our primary database for some data about products. One document in Elasticsearch is one product, which have some predictable properties (like price, name,...). This products are imported from some XML files and we want to somehow store all elements related to this product and then make queries like
WHERE element.ELEMENT_NAME = 'something'... (where our app does not have any idea which elements can be in XML - we need to process almost any XML which our user provides).
Do you have any suggestion, how to store this data in Elasticsearch? I think, that I cant create mapping for this, because there can be really lot of elements, which then produces a lot of fields in mapping.
You can define mapping for known fields. ElasticSearch will detect data type and create appropriate mapping for undefined field whenever it sees it in a document. Refer to https://www.elastic.co/guide/en/elasticsearch/reference/current/dynamic-mapping.html
At that point the index mapping will include the new field besides those defined by you. As you mentioned number of fields will keep growing. If you are expecting thousands of such fields it's not optimal.
If you don't care about searching unknown fields, you can turn off dynamic mapping. You _source will have data for these new field. But you won't be able to search on these fields.
This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.