我正在执行以下查询:
ns.ns
字段已配置(成功设置了映射和设置),但是该字段没有源数据。我得到从ElasticSearch返回的空结果。那正确吗?我的意思是,没有数据,此查询将返回空结果,对吗?仍在学习ES,感谢您的帮助。
最佳答案
The
ns.ns
field has configured (has both mapping and setting set up successfully) but there is no source data for this field. and I get empty result returned from ElasticSearch. is that right? without data this query would return an empty result, is that correct?
如前所述,
ns
字段被映射为nested
类型,因此,当您点击搜索查询时,由于该索引已经存在,因此不会得到"index_not_found_exception"
。search API返回与请求中定义的查询匹配的搜索命中。
当您点击上面问题中提到的搜索查询时,将出现以下响应:
{
"took": 17,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 0,
"relation": "eq"
},
"max_score": null,
"hits": []
}
}
该响应提供有关search request的以下信息:took – how long it took Elasticsearch to run the query, in milliseconds
timed_out – whether or not the search request timed out
_shards – how many shards were searched and a breakdown of how many shards succeeded, failed, or were skipped.
max_score – the score of the most relevant document found
hits.total.value - how many matching documents were found
上面的
hits.hits
返回一个空数组([]
),hits.hits
是找到的符合搜索条件的文档的数组。由于此处没有索引文档,因此在命中搜索查询时不会匹配任何文档。请参阅此ES文档,以了解有关how scoring works in ES的更多信息
In the above response
max_score
value isNULL
, the _score in Elasticsearch is a way of determining how relevant a match is to the query.
关于elasticsearch - 对于没有数据的字段,对嵌套 bool 查询返回空结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63872172/