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" }}}
]
}
}
}
- title字段包含
search
这个词 - content字段包含
elasticsearch
这个词 - status字段包含确切的词
published
- 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上下文中使用其他查询字句。
网友评论