gpt4 book ai didi

elasticsearch - 如何从ElasticSearch获取详细的结果输出

转载 作者:行者123 更新时间:2023-12-03 02:09:47 25 4
gpt4 key购买 nike

当我这样查询时:

curl 'http://localhost:9200/xenforo/_search?q=message:test'

我得到以下结果:
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 12.816886,
"hits": [
{
"_index": "xenforo",
"_type": "post",
"_id": "1778114",
"_score": 12.816886
}
]
}
}

显示了重要的_id,但是我将如何获取更多信息,例如日期,用户和节点信息。

这是我的一些映射信息,我认为重要的部分已显示:
curl -X GET 'http://localhost:9200/xenforo/_mapping?pretty=true'
{
"xenforo113" : {
"post" : {
"_source" : {
"enabled" : false
},
"properties" : {
"date" : {
"type" : "long",
"store" : "yes"
},
"discussion_id" : {
"type" : "long",
"store" : "yes"
},
"message" : {
"type" : "string"
},
"node" : {
"type" : "long"
},
"thread" : {
"type" : "long"
},
"title" : {
"type" : "string"
},
"user" : {
"type" : "long",
"store" : "yes"
}
}
},

我假设我将需要进行DSL查询,但是我不知道哪个命令会在结果中显示我想要的其他信息。

最佳答案

禁用_source时,您需要询问显式字段:

curl 'http://localhost:9200/xenforo/_search -d '{
"fields" : ["user", "date", "node"],
"query" : {
"match" : { "message" : "test" }
}
}'

参见 documentation

关于elasticsearch - 如何从ElasticSearch获取详细的结果输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15990665/

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