如何将分数模式从“总和”更改为“最高”

时间:2019-04-29 23:27:12

标签: elasticsearch mapping settings scoring


对不起,我的英文))
告诉我如何在nGram字段上将分数模式从“总和”更改为“最高”?
由于相加,elasticsearch给出的结果不适合我。我需要获取最大值,而不是金额。

信誉不允许附加图像。请看一下图像,它是什么样的“和”: https://discourse-cdn-sjc1.com/elastic/uploads/default/original/3X/6/5/65d113280a484faa9af3398ed73343cdb08c4075.png

索引

{
  "mappings": {
    "addresses": {
      "properties": {
        ...........................
        "tokensName": {
          "type": "text",
          "analyzer": "tokens",
          "similarity": "scripted_tfidf"
        }
        ...........................
      }
    }
  },
  "settings": {
    "similarity": {
      "scripted_tfidf": {
        "type": "scripted",
        "script": {
          "source": "double tf = 1.0; double idf = 1.0; double norm = 1.0; return query.boost * tf * idf * norm * weight;"
        }
      }
    },
    "analysis": {
      "filter": {
        "shingle": {
          "type": "edge_ngram",
          "min_gram": 1,
          "max_gram": 20
        }
      },
      "analyzer": {
        "tokens": {
          "type": "custom",
          "tokenizer": "whitespace",
          "filter": [
            "lowercase",
            "shingle"
          ]
        }
      }
    }
  }
}


文档

{
  ...........................
  "tokensName": "ирпень точный университет"
  ...........................
}


搜索查询

{
  "size": 5,
  "query": {
    "match": {
      "tokensName": {
        "query": "ирпень фаворит ун точно",
        "analyzer": "standard",
        "fuzziness": "AUTO"
      }
    }
  },
  "explain": true
}

0 个答案:

没有答案