Dynamic field of elastic search, stored both analyzed and non-analytical

I am trying to index json documents in elasticsearch. I do not have a document outline, its dynamics.

I need to store fields both analyzed and not analyzed. I also need it to be dynamic.

  • Can we use dynamic templates for this?
  • Is it also possible to keep field names the same for both parsed and non-parsed?
  • Do I need to do any special processing when searching for these fields?
+4
source share
1 answer

You accomplish this with dynamic patterns yes, by creating a dynamic mapping for fields (or field patterns, for example, all rows), for example:

"dynamic_templates":[ { "template_myStringFields":{ "match":"somepattern", "mapping":{ "type":"multi_field", "fields":{ "{name}":{ "type":"string", "index":"not_analyzed", }, "_tokenized":{ "type":"string", "index":"analyzed", } } } } }... 

Then, in order to search both in the analysis and not be analyzed, you can use “pattern matching” if you do not like to search in both fields at the same time or look for the _all field if it matches any field. The field name is the same, but with postfix, for example myField._tokenized in the above example.

0
source

Source: https://habr.com/ru/post/1497866/


All Articles