作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将产品列表的标题与已知产品的数据库匹配。我的第一个想法是将已知产品及其元数据放入elasticsearch中,并尝试使用multi_match找到最佳匹配。我当前的查询是这样的:
{
"query": {
"multi_match" : {
"query": "Men's small blue cotton pants SKU123",
"fields": ["sku^2","title","gender","color", "material","size"],
"type" : "cross_fields"
}
}
}
最佳答案
如果要让Elasticsearch仅对满足特定条件的项目评分,则需要在过滤器上下文中使用terms query。
由于terms query
不会分析您的查询,因此您必须自己做。简单的方法是使用空格和小写标记,并生成如下所示的查询:
{
"query": {
"bool": {
"filter": {
"terms": {
"color": ["men's", "small", "blue", "cotton", "pants", "sku123"]
}
},
"must": {
"multi_match": {
"query": "Men's small blue cotton pants SKU123",
"fields": [
"sku^2",
"title",
"gender",
"material",
"size"
],
"type": "cross_fields"
}
}
}
}
}
关于elasticsearch - 如何强制mult_match中的某些字段具有完全匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42060348/
我是一名优秀的程序员,十分优秀!