Elasticsearch:只返回嵌套的inner_hits [英] Elasticsearch: Return only nested inner_hits
本文介绍了Elasticsearch:只返回嵌套的inner_hits的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下查询:
GET /networkcollection/branch_routers/_search/
{
"query": {
"nested": {
"path": "queries",
"query": {
"bool": {
"must": [
{ "match":
{ "queries.dateQuery": "20160101T200000.000Z" }
}
]
}
},
"inner_hits" : {}
}
}
}
这将返回hits对象(整个文档)以及inner_hits对象(嵌套在hits中)。
This returns both the "hits" object (the entire document), as well as the "inner_hits" object (nested inside of hits).
是否一种让我只返回出现在inner_hits结果中的匹配查询元素的方式,而不会得到整个文档?
Is there a way to for me to only return the matched "queries" element(s) which appear in the "inner_hits" results, without getting the whole document?
推荐答案
应该能够通过禁用 source-field ,通过指定_ source:false
Should be able to achieve it by disabling source-field at top-level by specifying "_source" : false
POST /networkcollection/branch_routers/_search/
{
"_source" : false,
"query": {
"nested": {
"path": "queries",
"query": {
"bool": {
"must": [
{ "match":
{ "queries.dateQuery": "20160101T200000.000Z" }
}
]
}
},
"inner_hits" : {}
}
}
}
这篇关于Elasticsearch:只返回嵌套的inner_hits的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文