gpt4 book ai didi

json - 仅获取ElasticSearch中的结果文档,而使用PHP库排除其他元数据

转载 作者:行者123 更新时间:2023-12-02 22:25:52 24 4
gpt4 key购买 nike

我目前的查询结果是

{
"took": 13,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "ABC",
"_type": "users",
"_id": "1",
"_score": 1,
"fields": {
"partial1": {
"uid": "1",
"pic": "21398129082209.jpg",
"utype": "m",
"user": "John Smith"
}
}
}
]
}
}

每秒通过不同的1000个查询返回的匹配数超过100000次。

我想从结果中排除其他元数据信息,特别是 _index 类型,因为我正在使用PHP库来检索文档并将其发送给客户端。因此,这会将我的 索引类型暴露给客户端,这可能是安全问题。目前我正在遍历类似的结果
 $ttl = count($results['hits']['hits']);
$lst = array();
for($i=0; $i<$ttl; $i++)
{
$lst[] = $results['hits']['hits'][$i]["fields"]["partial1"];
}

如果同时有数千个请求,这就是性能问题。并将结果文档发送到客户端时,他们尽可能快地输入一些内容。有什么出路吗?关于SO有一个问题,但是这个问题已经存在大约一年了,目前还不支持。或者我只需要做我正在做的事情?

最佳答案

使用“filter_path”查询参数。非常灵活。例如,仅对所有结果包括_source字段(从而排除响应中的所有其他元数据),请使用:?filter_path=hits.hits._source。我认为它从1.6开始就在其余的api中。

https://www.elastic.co/guide/en/elasticsearch/reference/2.x/common-options.html#_response_filtering

关于json - 仅获取ElasticSearch中的结果文档,而使用PHP库排除其他元数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21285524/

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