在Elasticsearch中检索多个inside _source文档

fdbelqdn  于 2022-12-11  发布在  ElasticSearch
关注(0)|答案(1)|浏览(148)

我检索了10,000个文档,但只需要包含在_source中的文档,不包括_source键
这是我的查询

GET geojson_entities/_search?filter_path=hits.hits._source
{
  "size": 10000,
  "_source": {
    "includes": [
      "type"
    ]
  }
}

这是hits.hits数组中的响应

[ 
   {
     "_source": {
         "type": "Feature",
       }
   },
   ...more
]

我正在寻找内部命中的格式。命中数组如下所示

[ 
    {
       "type": "Feature",
    },
    ...more
]

这些不是我获取的唯一字段,但为了清楚起见,我这样做了。
使用JavaScript,我可以执行以下操作

const results = response.map(res => res._source)

但是,有没有办法只使用Elasticsearch来实现这一点呢?

ct2axkht

ct2axkht1#

这在elasticsearch中是不可能的。你需要在elasticsearch之外或者在应用程序级别使用java脚本。

相关问题