Я использую 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
?