在elasticsearch中使用带span\u multi的模糊和前缀匹配

olqngx59  于 2021-06-14  发布在  ElasticSearch
关注(0)|答案(1)|浏览(373)

我的用例是在基于模糊和前缀匹配检索的字段中突出显示多个短语/单词。为此,我目前使用span\u near来处理短语,span\u multi允许在短语术语中使用模糊性。我还需要使用前缀长度,这样模糊只允许前缀匹配后的字符,但span\u 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
                  }

  }
    }

}
tjrkku2a

tjrkku2a1#

嘿,原来是和

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

相关问题