我正在努力解决以下Elasticsearch问题:
使用以下主体获取/myindex/mytype/_search
:
{
"query": {
"bool": {
"should": [
{
"prefix": {
"name": "attorneys"
}
},
{
"multi_match": {
"query": "attorneys",
"type": "most_fields",
"fields": [
"name^2",
"description"
]
}
},
{
"nested": {
"boost": 2.0,
"path": "categories",
"score_mode": "sum",
"query": {
"bool": {
"should": [
{
"match": {
"categories.name": {
"fuzziness": 10,
"query": "attorneys"
}
}
},
{
"term": {
"categories.name": "attorneys"
}
}
]
// ...closing brackets trimmed for conciseness
不会返回ID = 10007的文档。
但是,具有完全相同的查询正文的GET
/myindex/mytype/10007/_explain
返回:{
"_index": "vendors",
"_type": "vendor",
"_id": "10007",
"matched": true,
"explanation": {
"value": 0.26991397,
"description": "product of:",
"details": [
{
"value": 0.8097419,
"description": "sum of:",
"details": [
{
"value": 0.8097419,
"description": "Score based on child doc range from 304 to 304"
}
]
},
{
"value": 0.33333334,
"description": "coord(1/3)"
}
]
}
}
为什么
_explain
返回"matched": true
但_query
不返回文件?
最佳答案
您的查询匹配多少个结果?由于您未指定from / size,因此默认值为返回前10个结果。也许文档10007来得晚。
关于elasticsearch - 为什么_explain返回的文档匹配:_search不返回true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30224865/