Type matching in one field in elasticsearch

Is there a way to boost search results in the same field depending on type?

My basic enhancement is something like:

 GET _search { "query": { "simple_query_string": { "query": "mangan", "fields":["_all", "title^6"] } } } 

But for some other documents, I want the title to be less important, so I tried prefixing it with a type:

 GET _search { "query": { "simple_query_string": { "query": "mangan", "fields":[ "_all", "DocumentationPage.title^6", "DocumentationPage.title^6"] } } } 

But then it does not increase at all. As a last resort, I could use Funcsion / Script Score bu to avoid it.

As an example, suppose a document contains only the title field.

+1
full-text-search elasticsearch relevance
Jan 23 '17 at 17:33
source share
1 answer

An easy way to achieve this is to re-write the query in the OP as a dis-max query .

Example for elasticsearch 5.x:

  { "query": { "dis_max": { "queries": [ { "simple_query_string": { "fields": [ "_all" ], "query": "mangan" } }, { "bool": { "filter": { "type": { "value": "DocumentationPage" } }, "must": [ { "simple_query_string": { "fields": [ "title^6" ], "query": "mangan" } } ] } } ] } } } 
+1
Jan 23 '17 at 18:53 on
source share
— -



All Articles