gpt4 book ai didi

elasticsearch - 在ElasticSearch搜索查询中获取文档的所有字段

转载 作者:行者123 更新时间:2023-12-02 22:20:35 24 4
gpt4 key购买 nike

如何获取与搜索查询匹配的文档中的所有字段?关于fields的ES文档说,使用*,可以获取所有字段:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-fields.html

有了此文档和此查询,我得到结果,但没有返回任何字段:

放置文件:

curl -XPUT http://localhost:9200/idx/t/doc1 -d '{
"f": "value"
}'

搜索一下:
curl -XPOST http://localhost:9200/idx/_search?pretty -d '{
"fields": "*",
"query": { "term" : { "f" : "value" }}
}'

我也尝试过 ["*"],但是结果是一样的,只返回默认字段( _id_type)。响应的点击部分如下所示:
"hits" : {
"total" : 1,
"max_score" : 0.30685282,
"hits" : [ {
"_index" : "idx",
"_type" : "t",
"_id" : "doc1",
"_score" : 0.30685282
} ]
}

最佳答案

The doc实际上说:

"* can be used to load all stored fields from the document."



core types doc表示存储字段的默认值为“false”。

Since by default ElasticSearch stores all fields of the source document in the special _source field, this option is primarily useful when the _source field has been disabled in the type definition. Defaults to false.



如果您未在搜索中指定“字段”,则可以查看_source中的内容。

因此,如果要将其作为字段返回,请更改映射以存储该字段。

关于elasticsearch - 在ElasticSearch搜索查询中获取文档的所有字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27865818/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com