【发布时间】:2017-06-26 21:11:53
【问题描述】:
在进行搜索时,Elasticsearch 会返回一个包含各种元信息的数据结构。
实际结果集包含在从数据库返回的 JSON 结果中的“hits”字段中。
Elasticsearch 是否可以只返回所需的数据(然后是“命中”字段的内容)而不嵌入到所有其他元数据中?
我知道我可以将结果解析为 JSON 并提取它,但我不希望复杂性、麻烦和性能损失。
谢谢!
这是 Elasticsearch 返回的数据结构示例。
{
"_shards":{
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits":{
"total" : 1,
"hits" : [
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_source" : {
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
}
]
}
}
【问题讨论】:
-
我相信能够控制 ES 返回的内容是一个重要的特性。例如,如果想要将从 ES 返回的结果合并到可重现的文档中。
标签: elasticsearch