【问题标题】:Elasticsearch decay parametersElasticsearch 衰减参数
【发布时间】:2015-07-03 20:47:59
【问题描述】:

我有三组文档(例如来自已注册、已验证和未注册用户的文档),我想使用衰减函数对它们进行评分。

但是,我需要为这三组文档中的每一个设置不同的衰减速度(规模),以便来自已验证用户的文档比来自未注册用户的文档更长。

看来,不能使用 doc 字段作为衰减函数的参数。也许,还有其他方法可以实现我想要的吗?

【问题讨论】:

    标签: elasticsearch scoring


    【解决方案1】:

    可以通过function_score,函数定义的“过滤器”来完成:

    {
      "size": 100,
      "query": {
        "function_score": {
          "score_mode": "multiply",
          "query": {
            "bool": {
              "must": [
                {
                  "term": {
                    "status": 0
                  }
                },
                {
                  "term": {
                    "categories": 29
                  }
                }
              ]
            }
          },
          "functions": [
            {
              "filter": {
                "term": {
                  "user_type": 1
                }
              },
              "weight": 1,
              "gauss": {
                "date_created": {
                  "scale": "7d",
                  "decay": 0.9
                }
              }
            },
            {
              "filter": {
                "not": {
                  "term": {
                    "user_type": 1
                  }
                }
              },
              "weight": 0.8,
              "gauss": {
                "date_created": {
                  "scale": "7d",
                  "decay": 0.8
                }
              }
            }
          ]
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-06
      • 1970-01-01
      • 2019-11-22
      • 1970-01-01
      • 2018-10-25
      相关资源
      最近更新 更多