在某些情況下,我不需要響應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