elasticsearch - 对于没有数据的字段,对嵌套 bool 查询返回空结果

标签 elasticsearch

我正在执行以下查询:
enter image description herens.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 is NULL, 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/

相关文章:

elasticsearch - 在Elasticsearch中找到 friend 的 friend

python - 使用 python 代码启动 elasticsearch 服务器

elasticsearch - 什么是 logstash 的 beats 插件?

curl - 移动聚合 ElasticSearch

elasticsearch - logstash转换为日期,并且仅在kibana中使用日期部分

javascript - 如何自定义kibana的界面

elasticsearch - Elasticsearch 多重匹配 : Is there a way to search all fields except one?

elasticsearch - 数组中的术语过滤器只考虑最后一项?

elasticsearch - 使用 Xamarin.Forms 与 NEST 的 Guid ID 比较不起作用

elasticsearch - 像GROUP BY AND HAVING这样的SQL示例