【问题标题】:Using Fuzzy and Prefix match with Span_multi in ElasticSearch在 ElasticSearch 中使用模糊和前缀匹配与 Span_multi
【发布时间】:2021-02-11 19:03:35
【问题描述】:

我的用例是在基于模糊和前缀匹配检索的字段中突出显示多个短语/单词。为此,我目前使用 span_near 来处理短语,并使用 span_multi 来允许在我的短语术语中使用模糊性。我还需要使用 prefix_length 所以模糊只允许前缀匹配后的字符,但 span_multi 不允许超过一个多词查询。有没有其他方法可以做到这一点?

    "query":{
    "bool":{
        "should":[{
  "span_near": {
    "clauses": [
      {
        "span_multi": {
          "match": {
            "fuzzy": {
              "comment": {
                "fuzziness": "5",
                "value": "Beata"
              }
            }
          }
        }
      },
        {
        "span_multi": {
          "match": {
            "fuzzy": {
              "comment": {
                "fuzziness": "5",
                "value": "Rosenane"
              }
            }
          }
        }
      }
    ],
    "in_order": False,
  }},{
  "span_near": {
    "clauses": [
      {
        "span_multi": {
          "match": {
            "fuzzy": {
              "comment": {
                "fuzziness": "5",
                "value": "Christna"
              }
            }
          }
        }
      }
    ],
    "in_order": False,
  }}]
}
},
    "highlight" : {
    "fields" : {
      "comment" : { "pre_tags" : ["<temp>"], "post_tags" : ["</temp>"],
                   "number_of_fragments" : 0
                  }

  }
    }
    
}

【问题讨论】:

    标签: python elasticsearch lucene elasticsearch-dsl pylucene


    【解决方案1】:

    嘿,它正在使用

    "comment": {
                    "fuzziness": "5",
                    "value": "Rosenane",
                    "prefix_match":3
                  }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-01
      • 2014-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-08
      • 2018-03-22
      相关资源
      最近更新 更多