我正在使用Elasticsearch 6.8。我的索引中有一个文档,如下所示:
$ curl "http://localhost:9200/users/_search"|jq
{
"took": 2,"timed_out": false,"_shards": {
"total": 1,"successful": 1,"skipped": 0,"failed": 0
},"hits": {
"total": {
"value": 1,"relation": "eq"
},"max_score": 1,"hits": [
{
"_index": "users","_type": "1","_id": "WzLeNG4BVtGh82ZM-BBl","_score": 1,"_source": {
"name": "joey","description": "xpxpxp all xpxpxp"
}
}
]
}
}
如果我在下面的查询中使用它,确实会向我返回文档。
{
"query": {
"bool": {
"filter": {
"term": {
"name": "joey"
}
},"should": [
{
"constant_score": {
"filter": {
"match_phrase": {
"description": "xpxpxp dd All xpxpxp"
}
}
}
}
]
}
}
}
但是如果我使用以下查询,它什么也不会返回:
{
"query": {
"bool": {
"should": [
{
"constant_score": {
"filter": {
"match_phrase": {
"description": "xpxpxp dd All xpxpxp"
}
}
}
}
]
}
}
}
这两个查询请求的不同之处在于,第一个查询在filter
之前有一个should
。我不知道为什么这会改变should
的行为?