【发布时间】:2016-03-04 21:29:40
【问题描述】:
我想从多个嵌套级别字段中进行搜索。查询喜欢。
select * from product where brand='brand1' and category='category1'.
在 elasticsearch 中,我有 两个嵌套级别映射,一个是 category,另一个是 brand。
如果我写了仅品牌或类别它返回完美结果但如何在以下查询中同时写?
$params = [
'index' => 'my_index',
'type' => 'product',
'body' => [
"query"=>[
"filtered"=>[
"filter"=>[
"bool"=>[
"must"=>[
"bool"=>[
"must"=>[
[
"query"=>[
"match"=>[
"brand"=>[
"query"=>"brand1",
"type"=>"phrase"
]
]
]
],
[
"query"=>[
"match"=>[
"category"=>[
"query"=>"category1",
"type"=>"phrase"
]
]
]
]
]
]
]
]
]
]
]
]
];
通过上述查询,我得到 0 个结果
【问题讨论】:
-
我不知道如何编写该查询?
标签: laravel elasticsearch