elasticsearch - Elasticsearch衰减函数得分

标签 elasticsearch

我正在尝试以下

PUT test/foo/1
{
  "num": 100
}

GET test/foo/_search
{
  "query" : {
    "function_score" : {
      "query" : {
        "match" : {
          "num": 100
        }
      },
      "functions" : [
        {
          "filter" : {
            "match_all" : {
            }
          },
          "gauss" : {
            "num" : {
              "origin": 0,
              "scale" : 500,
              "offset" : 0,
              "decay" : 0.1
            },
            "multi_value_mode" : "MIN"
          }
        }
      ],
      "score_mode" : "sum",
      "max_boost" : 3.4028235E38
    }
  }
}

---

{  
  "hits": {
    "total": 1,
    "max_score": 0.91201085,
    "hits": [
      {
        "_index": "test",
        "_type": "foo",
        "_id": "1",
        "_score": 0.91201085,
        "_source": {
          "num": 100
        }
      }
    ]
  }
}

我使用总和作为评分模式。因为查询的分数是1,衰减函数的分数是0.91201085,所以我期望分数是1.91201085。我想念什么?

最佳答案

使用“boot_mode”:“sum”。您还可以在查询中使用explain了解文档的评分方式

POST testindexy/_search
{
  "query" : {
    "function_score" : {
      "query" : {
        "match" : {
          "num": 100
        }
      },
      "functions" : [
        {
          "filter" : {
            "match_all" : {
            }
          },
          "gauss" : {
            "num" : {
              "origin": 0,
              "scale" : 500,
              "offset" : 0,
              "decay" : 0.1
            },
            "multi_value_mode" : "MIN"
          }
        }
      ],
      "boost_mode": "sum", 
      "score_mode" : "sum",
      "max_boost" : 3.4028235E38
    }
  }
}

关于elasticsearch - Elasticsearch衰减函数得分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42270038/

相关文章:

null - 如何在Elasticsearch结果中允许空值?

c# - NEST - 使用 GET 而不是 POST/PUT 进行搜索

elasticsearch - Elasticwhere NEST条件为

java - 如何模拟 ElasticSearch 客户端

elasticsearch - Elasticsearch 中的空白查询问题

elasticsearch - 如何在Elasticsearch的术语内使用OR?

elasticsearch - 无法引导 Elasticsearch v7.4.0 3 节点集群

Elasticsearch 映射 - 重命名现有字段

.net - Elastic NEST 在具有内部关键字字段的文本字段上使用术语过滤器

python - 如何在Elasticsearch DSL(elasticsearch-dsl-py)中使用存储桶,指标或管道用于多层聚合