【发布时间】:2018-05-16 21:26:34
【问题描述】:
我有文档(父)和页面(子)的父子关系。我想编写一个查询,从某个文档中获取与搜索字符串匹配的所有页面,以及检索 sn-ps。到目前为止我的代码(使用 php 库):
[
'size' => 100,
'from' => 0,
//this sets the snippets with highlight
'highlight' => [
'fields' => [
'content' => (object)[]
]
],
'query' => [
'bool' => [
'must' => [
'match' => [
'content' => $_GET['search']
],
//only get pages in this doc
/*'parent_id' => [
'type' => 'page',
'id' => $hit['_id']
]*/
'has_parent' => [
'type' => 'document',
'ids' => [
'values' => [$hit['_id']]
]
]
],
/*'filter' => [
'term' => [
'_parent' => $hit['_id']
]
]*/
]
],
];
如您所见,我尝试了过滤器、has_parent 和 parent_id 子句,但似乎没有任何效果,返回空集或错误。有没有人对如何做到这一点有任何指示?
谢谢!
【问题讨论】:
标签: elasticsearch