是否可以将GET定义为不返回ES数据存储中的id、索引、类型和/或分数



从数据存储执行GET时,我会在body.hits.hits中返回_id_index__type_score,但只希望数据在_source

例如:

[
{
"_index": "first-entry",
"_type": "_doc",
"_id": "IRQf0nkBaWzRmI7XDody",
"_score": 0.2876821,
"_source": {
"Hello": "World!"
}
},
{
"_index": "first-entry",
"_type": "_doc",
"_id": "IhQr0nkBaWzRmI7XZIeC",
"_score": 0.2876821,
"_source": {
"Hello": "world!"
}
}
]

有没有一种方法可以过滤掉这些信息,或者只是将其排除在外?

您可以使用响应过滤来实现此目的:

GET index/_doc/123?filter_path=hits.hits._source

最新更新