小编典典

Elasticsearch-如何仅返回数据,而不返回元信息?

elasticsearch

搜索时,Elasticsearch返回包含各种元信息的数据结构。

实际结果集包含在从数据库返回的JSON结果内的“ hits”字段中。

Elasticsearch是否有可能仅返回所需的数据(然后是“ hits”字段的内容)而没有嵌入所有其他元数据中?

我知道我可以将结果解析为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"
                }
            }
        ]
    }
}

阅读 1162

收藏
2020-06-22

共1个答案

小编典典

不,目前不可能。如果主要关注性能和解析复杂性,则可能需要考虑使用其他客户端:例如java客户端Thrift插件

2020-06-22