我目前的查询结果为
{
"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 和 type 当我使用PHP库检索文档并将其发送给客户端时。因此,这将我的 index 和 type 公开了可能是安全问题的客户端。目前,我正在通过
的结果循环 $ttl = count($results['hits']['hits']);
$lst = array();
for($i=0; $i<$ttl; $i++)
{
$lst[] = $results['hits']['hits'][$i]["fields"]["partial1"];
}
如果有成千上万的请求,这是性能问题。并将结果文档发送给客户端,因为它们键入的内容需要尽可能快地更快。有办法出路吗?有一个问题,但这大约一年了,说这是不支持的。或者我只需要做我正在做的事情?
使用" 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