Use of filtered query?

Hi,

I went through following query

{
  "filtered": {
    "query": {
      "match": { "tweet": "full text search" }
    },
    "filter": {
      "range": { "created": { "gte": "now-1d/d" }}
    }
  }
} 

The filtered query is used to filter the result set .

In the above query,after finding the yesterday's documents the filtered query is used to get the documents that match the particular field(i.e.tweet).

Correct me if my understanding is wrong.

Thanks..

Since this is a post_filter after match query the filter works ..

Hey,

a post filter is applied after the search is executed, so it only makes sense to filter out documents there, not to execute another query, because the post filter does not apply scoring - this part needs to go into your regular query. See https://www.elastic.co/guide/en/elasticsearch/reference/5.2/search-request-post-filter.html

Unless you are using aggregrations, there is no need for the post filter.

--Alex

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.