There is such a question, is it possible to put the option "not_analyzed" when searching in elasticsearch, or maybe there is a way to create a template on the server and use it, I just want to search for the same index with or not him
1 answer
To present one field as with / without not_analyzed, you need to use Multi Field. This is useful when sorting by field, which is also used in full-text search.
Multifield mapping:
"mappings": { "product": { "properties": { "name": { "type": "string", "analyzer": "russian", "fields": { "raw": { "type": "string", "index": "not_analyzed" } } } } } } An example of a query that uses the name field and subfield (subfield) name.raw:
{ "query": { "match": { "name": "смартфон" } }, "sort": "name.raw" } - And at the same time, raw is filled by itself, or do you need to add data to raw too ??? - pnp2000
- You do not need to fill raw, everything does elasticsearch for you. Only {"name" is sent: "Name of something"}. "raw" is an arbitrary name, and you might as well call the subfield differently, for example sort. - Andrey Morozov
|