匹配的多术语查询错误结果

问题描述 投票:0回答:1

看起来像我试图模糊匹配多术语查询时缺少明显的东西。

我想实现的是在提供“ Goleniow Heleniow”查询(带有Typo的City + District名称)时,仅获得“ Goleniow Helenow”。相反,我得到了所有文档。 基本上,我认为我尝试了所有组合

Minimum_should_match

操作器甚至fuzziness参数,没有令人满意的结果。 任何人都可以指出我想念什么? 索引设置

curl -X PUT "localhost:9200/test-index?pretty" -H 'Content-Type: application/json' -d' { "settings": { "number_of_shards": 1 }, "mappings": { "properties": { "name": { "type": "text", "index": true } } } }'

docs toIndex

curl -X POST "localhost:9200/test-index/_doc?pretty" -H 'Content-Type: application/json' -d' { "name": "Goleniow Helenow" }' curl -X POST "localhost:9200/test-index/_doc?pretty" -H 'Content-Type: application/json' -d' { "name": "Goleniow" }' curl -X POST "localhost:9200/test-index/_doc?pretty" -H 'Content-Type: application/json' -d' { "name": "Goleniow Jaworow" }'

suquery andesultion
curl -X POST "localhost:9200/test-index/_search?pretty" -H 'Content-Type: application/json' -d'{
  "query": {
    "match": {
      "name": {
        "minimum_should_match": "100%",
        "operator": "and",
        "fuzziness": "2",
        "query": "Goleniow Heleniow"
      }
    }
  }
}'
{
  "took" : 104,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 0.32180583,
    "hits" : [
      {
        "_index" : "test-index",
        "_id" : "Waqnj5UBnvH7uZURvQTX",
        "_score" : 0.32180583,
        "_source" : {
          "name" : "Goleniow Helenow"
        }
      },
      {
        "_index" : "test-index",
        "_id" : "Wqqoj5UBnvH7uZUR2QSO",
        "_score" : 0.2793999,
        "_source" : {
          "name" : "Goleniow"
        }
      },
      {
        "_index" : "test-index",
        "_id" : "W6qoj5UBnvH7uZUR8AT4",
        "_score" : 0.21600665,
        "_source" : {
          "name" : "Goleniow Jaworow"
        }
      }
    ]
  }
}

您可以使用

span_near

查询。
here
是类似的讨论。
elasticsearch fuzzy-search elasticsearch-dsl
1个回答
0
投票

GET test-index/_search { "query": { "bool": { "must": [ { "span_near": { "clauses": [ { "span_multi": { "match": { "fuzzy": { "name": { "value": "Goleniow", "fuzziness": 2 } } } } }, { "span_multi": { "match": { "fuzzy": { "name": { "value": "Heleniow", "fuzziness": 2 } } } } } ], "slop": 0, "in_order": true } } ] } } }


© www.soinside.com 2019 - 2025. All rights reserved.