Home > Software engineering >  Elasticsearch validate query API fails for query with highlight
Elasticsearch validate query API fails for query with highlight

Time:11-25

I am trying to use highlight with my query as mentioned here: https://www.elastic.co/guide/en/elasticsearch/reference/current/highlighting.html.

This query works correctly with search API but before actually executing the expensive query, I want to validate it using validation API provided by elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-validate.html

But this fails with an error message:

org.elasticsearch.common.ParsingException: request does not support [highlight]

So how can I validate the query with highlight without executing it?

I found a similar problem on ES discussion forum: https://discuss.elastic.co/t/validation-api-got-error-with-highlight-org-elasticsearch-common-parsingexception-request-does-not-support-highlight/248953 but it doesn't have any solution.

CodePudding user response:

It does not support highlighting (or any other param like sort, aggregation, size, from etc.) because the purpose of the validation API is to validate your query, and highlighting is done after the query is executed and get a response from the index.

Validates a potentially expensive query without executing it.

Hence, you can remove the highlighting when running the validation API and validating the query. after that you can add highlghtng in actual query.

  • Related