在某些情况下,我不需要响应json中的所有字段。更改ElasticSearch响应的结构json
例如,
// request json
{
"_source": "false",
"aggs": { ... },
"query": { ... }
}
// response json
{
"took": 123,
"timed_out": false,
"_shards": { ... },
"hits": {
"total": 123,
"max_score": 123,
"hits": [
{
"_index": "foo",
"_type": "bar",
"_id": "123",
"_score": 123
}
],
...
},
"aggregations": {
"foo": {
"buckets": [
{
"key": 123,
"doc_count": 123
},
...
]
}
}
}
其实我并不需要_index
/_type
每次。当我做聚合时,我不需要hits
块。
"_source" : false
或"_source": { "exclude": [ "foobar" ] }
可以帮助忽略/排除hits
块中的_source
字段。
但是,我可以更常见的方式更改ES响应json的结构吗?谢谢。
我找到'“大小”:0'也就像'SEARCH_TYPE = count'。 – jasonz 2014-11-03 09:01:14
如何改变结构? 类似于: “fields”:[“fieldName1”:{“fieldName2”,etc ...}] 这可能吗? – Maxrunner 2015-03-06 14:37:21
您将无法直接在ElasticSearch中执行操作:这必须在客户端完成。 – ThomasC 2015-03-07 11:13:31