Query SQL的理解

作者: animagus | 来源:发表于2019-08-13 19:09 被阅读0次

query demo

如下所述是一个search的样例

GET /_search
{
  "query": { 
    "bool": { 
      "must": [
        { "match": { "title":   "Search"        }},
        { "match": { "content": "Elasticsearch" }}
      ],
      "filter": [ 
        { "term":  { "status": "published" }},
        { "range": { "publish_date": { "gte": "2015-01-01" }}}
      ]
    }
  }
}
  1. title字段包含search这个词
  2. content字段包含elasticsearch这个词
  3. status字段包含确切的词published
  4. publish_date字段包含一个从2015-1-1向后的日期

query参数指出了查询的上下文。

query上下文中使用了bool和两个match。这两个词表示了文档需要匹配的程度。

filter参数指出了过滤的上下文,他使用了term和range字句。They will filter out documents which do not match, but they will not affect the score for matching documents.

Tip:Use query clauses in query context for conditions which should affect the score of matching documents (i.e. how well does the document match), and use all other query clauses in filter context.

(这段不太懂)使用query字句在query上下文中应该影响到文档匹配程度的条件,在filter上下文中使用其他查询字句。

相关文章

网友评论

    本文标题:Query SQL的理解

    本文链接:https://www.haomeiwen.com/subject/pmobjctx.html