如何使用Elasticsearch根据短语中单词的顺序和距离对结果分数加权

如果我有一个搜索短语的查询,我如何让Elasticsearch根据短语中每个单词的顺序和距离而不是它们的存在来对分数进行加权?例如,如果我搜索“房屋出租”,则会构建查询:

{
  "query": {
    "bool": {
      "must": [{
        "query_string": {
          "query": "house for rent"
        }
      }]
    }
  }
}

此查询返回的结果按如下顺序排序:

"I am looking to rent a house" -> all terms present out of order with words in between
"I am looking for a house that would be for me to rent" -> all terms present in order with words in between
"I am looking for house to rent" -> 'house for rent' exactly
"I live in a house" -> only 1 term present

前3个结果中包含该短语中的所有单词,但有时会出现乱序或中间包含单词的情况。我希望确切的词组匹配得分最高,但事实并非如此。如何调整评分以考虑词组的顺序和距离?我可以使用query_string来实现还是要使用其他类型的查询?

xuanxixuan 回答:如何使用Elasticsearch根据短语中单词的顺序和距离对结果分数加权

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3165768.html

大家都在问