Not analyzed request in the analyzed field

I have a specific document that stores brand names in the analyzed form for ex: {"name": "Samsung"} {"name": "Motion Systems"}. There are times when I need to search by a term starting with "s", which should lead to both documents. and another case where I want only a full field starting with the query β€œs”, which only returns β€œsamsung”. I analyzed the name field and saved it. Is there any way by which I can execute a complete field starting with a query in elastic search?

+4
source share
1 answer

You must index your field in two different ways using multi_field . If you do this the way you already do, you have a match based on the tokens created by the tokenizer. For the second type of match you want, you need to either disable field analysis and index it as is, or use Keyken tokenizer , which produce the same result. Your mapping will look like this:

{ "your_type" : { "properties" : { "brand" : { "type" : "multi_field", "fields" : { "brand" : {"type" : "string", "index" : "analyzed"}, "untouched" : {"type" : "string", "index" : "not_analyzed"} } } } } } 

Then you can search in both fields. When you search on brand , you get matches that you already have, when you search on brand.untouched you will get a second number of matches. There are several ways to collect multiple queries, you can see an example in bool query .

+6
source

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


All Articles