python - 在ElasticSearch中将模糊和前缀匹配与Span_multi一起使用

标签 python elasticsearch lucene elasticsearch-dsl pylucene

我的用例是在基于模糊和前缀匹配而检索的字段中突出显示多个短语/单词。为此,我目前使用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
                  }

  }
    }
    
}

最佳答案

嘿,它正在与

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

关于python - 在ElasticSearch中将模糊和前缀匹配与Span_multi一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64589374/

相关文章:

elasticsearch - 将时间戳转换为日期时间以用于 Elasticsearch 聚合

performance - 在Elasticsearch中优化使用简单博客应用程序的类型和路由

c# - Lucene 检查索引大小

python - 查找字符串的条件

elasticsearch - 将 ElasticSearch 传输客户端与 Amazon ElasticSearch Service (AES) 结合使用

python - Pandas 集团 : apply a function with two arguments

elasticsearch - ES 7-将匹配查询与过滤器配合使用

java - lucene 不区分大小写的排序搜索

python - Python 文档中给出的 BeautifulSoup 示例不起作用

Python。 Pandas 。计算统计差异分组依据