弹性搜索 - 从json响应中排除索引和类型 [英] Elastic Search - exclude index and type from json response
本文介绍了弹性搜索 - 从json响应中排除索引和类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我通过这样的索引执行查询时:
When I execute a query over an index like this:
{
"_source":["bar"] , "size":100,
"query": {
"match_all": {}
},
"filter": {
"type" : {
"value" : "foo"
}
}
}
响应包括索引,类型等。但是我已经知道索引和类型,因为我指定它。这个信息只是膨胀了json数据的大小。有没有办法从回应中排除这些?
the response includes index, type, etc. But I already know the index and type because I specified it. This information just bloats up the size of the json data. Is there a way to exclude these from the response?
这是我得到的:
{
"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"
}
}
,...
我想要的是这样的,所以没有类型,分数,索引:
What I want is something like this, so a response without type,score,index:
{
"took": 31,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 364024,
"max_score": 1,
"hits": [
{
"_id": "asdjj123123",
"_source": {
"bar": "blablablabla"
}
}
,...
推荐答案
是的,从ES 1.6起,您可以使用 filter_path $ c $($)$ / $ / $ / $ / $ select /查询中的c>参数只枚举响应中需要的内容:
Yes, as of ES 1.6, you can use response filtering and using the filter_path
parameter in the query enumerate only what you need in the response:
curl -XGET 'localhost:9200/foo_bar/foo/_search?pretty&filter_path=hits.total,hits.max_score,hits.hits._id,hits.hits._source'
这篇关于弹性搜索 - 从json响应中排除索引和类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文