gpt4 book ai didi

laravel - 从Elasticsearch中的多个嵌套级别字段中搜索

转载 作者:行者123 更新时间:2023-12-03 00:16:25 26 4
gpt4 key购买 nike

我想从多个嵌套级别字段中搜索。查询一样。

select * from product where brand='brand1' and category='category1'.

在elasticsearch中,我有 两个嵌套级别映射,一个是 类别,另一个是 品牌

如果我只写 品牌或类别 ,则返回完美结果,但 如何在下面的查询中同时写这两个单词?
    $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个结果

最佳答案

您可以在下面的查询中尝试它,它将帮助您获得尊敬的答案:

GET / product / ur_type / _search
{
“来自”:0,
“大小”:200,
“查询”:{
“已过滤”:{
“过滤器”:{
“ bool(boolean) ”:{
“必须”:{
“ bool(boolean) ”:{
“必须”:[
{
“查询”:{
“比赛”: {
“牌”: {
“query”:“brand1”,
“type”:“短语”
}
}
}
},
{
“查询”:{
“比赛”: {
“类别”:{
“query”:“category1”,
“type”:“短语”
}
}
}
}
]
}
}
}
}
}
}
}

关于laravel - 从Elasticsearch中的多个嵌套级别字段中搜索,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35794957/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com