1、fuzzy查询放在filter里
{
"size": 0,
"query": {
"bool": {
"filter": {
"fuzzy": {
"queryKeyword": {
"value": "男士拖鞋",
"fuzziness": 2,
"max_expansions": 50,
"transpositions": true
}
}
}
}
}
}
结果:
"hits" : {
"total" : 845274,
"max_score" : 0.0,
"hits" : [ ]
}
2、fuzzy查询放在must里
{
"size": 0,
"query": {
"bool": {
"must": {
"fuzzy": {
"queryKeyword": {
"value": "男士拖鞋",
"fuzziness": 2,
"max_expansions": 50,
"transpositions": true
}
}
}
}
}
}
结果:
"hits" : {
"total" : 47801,
"max_score" : 0.0,
"hits" : [ ]
}
这是什么原因呢?
{
"size": 0,
"query": {
"bool": {
"filter": {
"fuzzy": {
"queryKeyword": {
"value": "男士拖鞋",
"fuzziness": 2,
"max_expansions": 50,
"transpositions": true
}
}
}
}
}
}
结果:
"hits" : {
"total" : 845274,
"max_score" : 0.0,
"hits" : [ ]
}
2、fuzzy查询放在must里
{
"size": 0,
"query": {
"bool": {
"must": {
"fuzzy": {
"queryKeyword": {
"value": "男士拖鞋",
"fuzziness": 2,
"max_expansions": 50,
"transpositions": true
}
}
}
}
}
}
结果:
"hits" : {
"total" : 47801,
"max_score" : 0.0,
"hits" : [ ]
}
这是什么原因呢?
4 个回复
guoxiaoguo
赞同来自:
laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net
赞同来自:
guoxiaoguo
赞同来自:
"size": 10,
"query": {
"bool": {
"must": [
{
"term": {
"queryKeyword": "鞋柜"
}
},
{
"fuzzy": {
"queryKeyword": {
"value": "公",
"fuzziness": 2,
"max_expansions": 50,
"transpositions": true
}
}
}
]
}
}
}
把fuzzy放到must里匹配不到任何文档,
但是放到filter里是可以匹配到的
kennywu76 - Wood
赞同来自: