Elasticsearch: [filtered] request does not support [highlight]

I am new to Elasticsearch. I have a filtered query as shown below.

{ "query": { "filtered" : { "query" : { "term" : { "title" : "crime" } }, "highlight" : { "fields" : { "title" : {} } }, "filter" : { "term" : { "year" : 1961 } } } } } 

When I tried this request and got an error:

 [filtered] query does not support [highlight] 

Is filtered query support highlighted? If not, how can I achieve filters in the query? I have to use filters.

Thank you and welcome!

+6
source share
1 answer

The "highlight" parameter should go at the same level as the "query" parameter, and not built into it. In your case, it should look something like this:

 { "query": { "filtered" : { "query" : { "term" : { "title" : "crime" } }, "filter" : { "term" : { "year" : 1961 } } } }, "highlight" : { "fields" : { "title" : {} } } } 
+6
source

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


All Articles