gpt4 book ai didi

json - Elasticsearch - 从 json 响应中排除索引和类型

转载 作者:行者123 更新时间:2023-11-29 02:48:10 25 4
gpt4 key购买 nike

当我对这样的索引执行查询时:

{
"_source":["bar"] , "size":100,
"query": {
"match_all": {}
},
"filter": {
"type" : {
"value" : "foo"
}
}
}

response包括index,type等,但是index和type我已经知道了,因为我指定了。此信息只会膨胀 json 数据的大小。有没有办法从响应中排除这些?

这是我得到的:

{
"took": 31,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 364024,
"max_score": 1,
"hits": [
{
"_index": "foo_bar",
"_type": "foo",
"_id": "asdjj123123",
"_score": 1,
"_source": {
"bar": "blablablabla"
}
}
,...

我想要的是这样的,所以没有type,score,index的响应:

{
"took": 31,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 364024,
"max_score": 1,
"hits": [
{
"_id": "asdjj123123",
"_source": {
"bar": "blablablabla"
}
}
,...

最佳答案

是的,从 ES 1.6 开始,您可以使用 response filtering并在查询中使用 filter_path 参数仅枚举您在响应中需要的内容:

curl -XGET 'localhost:9200/foo_bar/foo/_search?pretty&filter_path=hits.total,hits.max_score,hits.hits._id,hits.hits._source'

关于json - Elasticsearch - 从 json 响应中排除索引和类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31569422/

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