10 Search Languages - Search and Filter

The behavior of the query clause depends on whether it is used in the query context or in the filter:
Query context: In addition to deciding whether to match the document, the query clause also knows how well the document matches the query. So he calculates a match score, which also depends on other documents.
Filter Context: In the filter context, it's more about answering whether the document matches the request. The result is only two yes or no. So there is no point calculation involved. More, filters involve structured data. Such as: whether the time is between 2015 and 2016.
For performance reasons, es caches frequently used filters.
As follows, the search title contains search, and the body contains elasticsearch. And the state is precisely published, and the release time is the data after 2015.1.1.
GET /_search
{
  "query": {
    "bool": {
      "must": [
        { "match": { "title":   "Search"        }},
        { "match": { "content": "Elasticsearch" }}  
      ],
      "filter": [
        { "term":  { "status": "published" }},
        { "range": { "publish_date": { "gte": "2015-01-01" }}}
      ]
    }
  }
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326529299&siteId=291194637