[ "multi_match" => [ -6ren">
gpt4 book ai didi

php - Elasticsearch php中具有AND条件的多匹配查询

转载 作者:行者123 更新时间:2023-12-02 22:22:46 24 4
gpt4 key购买 nike

我想使用AND条件在多个字段中搜索。我尝试了很多方法,但无法产生结果。

下面是我的代码。

   "query" =>[
"multi_match" => [
"fields" => ["prod_name", "prod_seo_name"],
"type" => "phrase_prefix",
"query" => $query
],
"bool" => [
"must" => [
"term" => [ "cat_type_id" => 1 ],

],
],
],

我想使用cat_type_id为1的产品名称进行搜索。

我也尝试过跟随。
"query" =>[
"multi_match" => [
"fields" => ["prod_name", "prod_seo_name"],
"type" => "phrase_prefix",
"query" => $query
],
"filter" => [
"term"=> ["cat_type_id"=>1]
]

任何帮助或引用将是巨大的。

最佳答案

正确的方法是这样的:

"query" => [
"bool" => [
"must" => [
[
"multi_match" => [
"fields" => ["prod_name", "prod_seo_name"],
"type" => "phrase_prefix",
"query" => $query
]
],
[
"term"=> ["cat_type_id"=>1]
]
]
]
]

关于php - Elasticsearch php中具有AND条件的多匹配查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46599042/

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