问题描述
我做一个查询,返回像70k的文档(我需要所有的,和目前使用扫描和滚动)
会发生什么是响应是非常大(2 MB和我们alredy减少从6 MB)。我们alredy过滤了我们需要的字段,因为查询只是从一个API调用,我们减少了属性的名称。
我可以看到的是,每个文档数组hits有以下默认字段,我真的不需要他们:
- _index(我们只请求一个索引) li>
- _type(我们只请求一种类型)
- _id(我们在字段中输入此字符)
- _score(我们不打分)
有没有办法删除它们,所以我可以有以下结构:
hits:[
pre>
{
_source:{
...
}
},
{
_source:{
...
}
}
]
感谢您阅读!
我将感谢您的帮助!解决方案是的,您可以使用和
filter_path
curl -XGET'localhost:9200 / _search?pretty& filter_path = hits.hits._source'
您甚至可以只指定所需的字段
curl -XGET'localhost:9200 / _search?pretty& filter_path = hits.hits._source& _source = title,name'
Im doing a query that returns like 70k documents (I need all of them, and Im currently using scan & scroll)
What happens is that the response is very large (2 MB and we alredy reduced it from 6 MB). We alredy filtered the fields we needed, and since the query is only called from an API we reduced the name of the properties.
What i can see is that every document in the array "hits" has the following default fields that i really dont need them:
- _index (we only request on one index)
- _type (we only request on one type)
- _id (we alredy have this on a field)
- _score (we are not scoring)
Is there a way to remove them so i can have the following structure:
"hits" : [
{
"_source": {
...
}
},
{
"_source": {
...
}
}
]
Thanks for reading!I will appreciate your help!
Yes, you can use response filtering and the filter_path
parameter, provided you're using ES 1.6 or later.
curl -XGET 'localhost:9200/_search?pretty&filter_path=hits.hits._source'
You can even specify the just the fields you want
curl -XGET 'localhost:9200/_search?pretty&filter_path=hits.hits._source&_source=title,name'
这篇关于Elasticsearch从搜索的响应正文中删除默认字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!