Elasticsearch filter

chapter


_score(Score) field is a measure of the degree of matching documents with a search condition indicator. The higher the score, the more relevant document, the lower the score, the more irrelevant documents. It is not always necessary to generate the score, or need Elasticsearch automatically determined, in order to avoid unnecessary calculation of scores.

Boolean queries also support filterclause to set the filter conditions. Filtering does not affect the relevance score of the document.

The following example, using Boolean query returns all the account balances of between 20000-30000.

API

GET /bank/_search
{
  "query": {
    "bool": {
      "must": { "match_all": {} },
      "filter": {
        "range": {
          "balance": {
            "gte": 20000,
            "lte": 30000
          }
        }
      }
    }
  }
}

CURL

curl -X GET "localhost:9200/bank/_search" -H 'Content-Type: application/json' -d'
{
  "query": {
    "bool": {
      "must": { "match_all": {} },
      "filter": {
        "range": {
          "balance": {
            "gte": 20000,
            "lte": 30000
          }
        }
      }
    }
  }
}
'

The above Boolean query contains a match_allquery (query part) and a rangequery (filter section). Filter conditions of rangethe query does not affect the document's relevance score is calculated.

In addition match_all, match, booland rangequeries, there are many other query types, works much the same, refer to the relevant information.

Guess you like

Origin www.cnblogs.com/jinbuqi/p/11504392.html