Elasticsearch 衰减参数

Elasticsearch decay parameters

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

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

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

可以用函数定义的function_score,"filter"来完成:

{
  "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
            }
          }
        }
      ]
    }
  }
}