社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Elasticsearch

Elasticsearch-如果匹配的单词越多,文档得分越高

Marcel Balzer • 6 年前 • 1156 次点击  

我有个问题,希望有人能帮助我。

我有一个搜索匹配查询的简单示例

"query": {
    "match": {
        "filterValues": "ordner ohne griffloch"
    }
}

我正好有两支安打:

"hits" : [
  {
    "_index" : "filters",
    "_type" : "filter",
    "_id" : "F-114150068-1170182",
    "_score" : 5.420828,
    "_source" : {
      "filterValues" : [
        "Ja",
        "Griffloch vorhanden",
        "Griffloch",
        "mit Griffloch"
      ]
    },
    "highlight" : {
      "filterValues" : [
        "<em>Griffloch</em>"
      ]
    }
  },
  {
    "_index" : "filters",
    "_type" : "filter",
    "_id" : "F-114150069-1170182",
    "_score" : 4.452639,
    "_source" : {
      "filterValues" : [
        "ohne Griffloch",
        "kein Griffloch",
        "Nein"
      ]
    },
    "highlight" : {
      "filterValues" : [
        "<em>ohne Griffloch</em>"
      ]
    }
  }
]

我的问题是:我想找到第二个热门歌曲“ohne Griffloch”作为第一个(更好的分数),因为它匹配更多的单词。但我发现第一个有更好的分数,我认为,因为它包含更多的“格里夫洛赫”。

我不能使用术语查询,因为当查询包含其他单词(这里是“ordner”)时,我将找不到任何内容,因为它与任何内容都不完全匹配。

有什么想法吗?

谢谢您!

有关信息,请参阅索引配置:

"settings": {
    "analysis": {
      "analyzer": {
        "default": {
          "type": "custom",
          "tokenizer": "keyword",
          "filter": [
            "lowercase"
          ]
        },
        "lowercase_shingle": {
          "tokenizer": "whitespace",
          "filter": [
            "lowercase",
            "my_shingle"
          ]
        }
      },
      "filter": {
        "my_shingle": {
          "type": "shingle",
          "min_shingle_size": 2,
          "max_shingle_size": 4
        }
      }
    }
  },
  "mappings": {
    "filter": {
      "properties": {
        "filterValueId": {
          "type": "long"
        },
        "filterValues": {
          "type": "text",
          "position_increment_gap": 100,
          "analyzer": "default",
          "search_analyzer": "lowercase_shingle"
        },
        "categoryId": {
          "type": "long"
        }
      }
    }
  }
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/50633
文章 [ 2 ]  |  最新文章 6 年前