How to wrap an ElasticSearch filter in a query

To use percolator in ElasticSearch, I need to index search queries. However, we mainly use filters for search. To index these filters, they must be wrapped in a query .

I know two different approaches to this. Wrap the filter in the filtered query :

{
  "query": {
    "filtered": {
      "filter": { ... }
    }
  }
}

or using the query for the score constant :

{
  "query": {
    "constant_score": {
      "filter": { ... }
    }
  }
}

Which method is preferred? Why?

+4
source share
2 answers

, filtered -query. . , .:)

+2

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


All Articles