[英]ElasticSearch: Returning products based on name and categories
im having troubles returning all the product that match a specific condition: 我在退回所有符合特定条件的产品时遇到了麻烦:
My mapping is quite simple 我的映射很简单
i have products, they have names, and they'are in certain categories. 我有产品,有名称,并且属于某些类别。
What i want to do is return all the product that either have a string that i choose in their name, aswell has returning all the product that also are in the category for the same string. 我想做的是返回所有具有我在其名称中选择的字符串的产品,以及返回也属于同一字符串类别的所有产品。
Here's an example: 这是一个例子:
say i type 'Mobile phone', i should get all the products that have 'Mobile Phone' somewhere in the string 'name' (order and such doesn't matter) but it should also return all the product in the 'Mobile Phone' category (whatever the name is) 说我输入“手机”,我应该将所有带有“手机”的产品放在字符串“名称”中(顺序无关紧要),但它还应该在“手机”中返回所有产品类别(无论名称如何)
At the moment, i have a query that gets a lot of garbage because it matchs any of the words in the name, and doesn't get all of the categories. 此刻,我有一个查询,该查询会产生大量垃圾,因为它与名称中的任何单词匹配,并且无法获取所有类别。
BoolQuery {#612 ▼
#_params: array:2 [▼
"must" => array:3 [▼
0 => ProductAvailable {#613 ▶}
1 => Term {#622 ▶}
2 => BoolQuery {#623 ▼
#_params: array:3 [▼
"minimum_number_should_match" => 1
"should" => array:2 [▼
0 => Match {#624 ▼
#_params: array:1 [▼
"name" => "Tondeuse à gazon"
]
#_rawParams: []
}
1 => Match {#625 ▼
#_params: array:1 [▼
"category.name.raw" => "Tondeuse à gazon"
]
#_rawParams: []
}
]
"boost" => 2
]
#_rawParams: []
}
]
"minimum_number_should_match" => 1
]
#_rawParams: []
}
The ProductAvailable and Term query aren't relevant since they're used to check if product can be selled etc... ProductAvailable和Term查询无关,因为它们用于检查产品是否可以出售等。
Here the example string is "Tondeuse à gazon" 此处的示例字符串为“ Tondeuseàgazon”
Thanks for the helping <3 感谢您的帮助<3
我自己找到了解决方案,我会将问题标记为已回答
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.