ben*_*nbo 6 json elasticsearch
当我对这样的索引执行查询时:
{
"_source":["bar"] , "size":100,
"query": {
"match_all": {}
},
"filter": {
"type" : {
"value" : "foo"
}
}
}
Run Code Online (Sandbox Code Playgroud)
响应包括索引,类型等.但我已经知道索引和类型,因为我指定了它.这些信息只会膨胀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"
}
}
,...
Run Code Online (Sandbox Code Playgroud)
我想要的是这样的,所以没有类型,分数,索引的响应:
{
"took": 31,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 364024,
"max_score": 1,
"hits": [
{
"_id": "asdjj123123",
"_source": {
"bar": "blablablabla"
}
}
,...
Run Code Online (Sandbox Code Playgroud)
是的,从ES 1.6开始,您可以使用响应过滤并使用filter_path查询中的参数仅枚举响应中所需的内容:
curl -XGET 'localhost:9200/foo_bar/foo/_search?pretty&filter_path=hits.total,hits.max_score,hits.hits._id,hits.hits._source'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1746 次 |
| 最近记录: |