【发布时间】:2016-08-02 20:25:46
【问题描述】:
我想使用 elasticsearch 创建热门搜索查询。
我想从 elasticsearch 表中匹配 category_name、brand_name 和 title。匹配应该是短语和 with or 条件。
我的查询:
$query = [
"bool" => [
"must" => [
["match" => ["is_published" => 1]],
[
"multi_match" => [
"query" => $searchKey,
"fields" => ["category_name", "brand_name", "title"]
]
],
[
'nested' => [
'path' => 'category_with_in_title.parent_cat',
'query' => [
'bool' => [
'must' => [
['match' => [
'category_with_in_title.parent_cat.status' => 1,
]],
],
],
],
],
],
[
'nested' => [
'path' => 'brand',
'query' => [
'bool' => [
'must' => [
'match' => [
'brand.approved_status' => 1,
],
],
],
],
],
],
[
'nested' => [
'path' => 'default_product_low_price_with_seller.seller_detail',
'query' => [
'bool' => [
'must' => [
'match' => [
'default_product_low_price_with_seller.seller_detail.approve_status' => 1,
],
],
],
],
],
],
[
'nested' => [
'path' => 'default_product_low_price_with_seller',
'query' => [
'bool' => [
'must' => [
'match' => [
'default_product_low_price_with_seller.status' => 1,
],
],
],
],
],
],
],
],
];
我为此使用multi_match,但如何在此查询中使用短语?我必须写整个单词才能搜索。
例如:
我要搜索category_name = Tops的记录
如果我写“tops”或“top”或“to”,我想要结果。但是现在我必须准确地写出“Tops”。
提前谢谢...
【问题讨论】:
标签: php search elasticsearch