es分数_score衰减函数

 

1.按日期衰变

GET news/doc/_search
{
  "query" : {
    "function_score": {
        "query": {"multi_match" : {
                "query" : "生物医药",
                "fields": ["title"],
                "type":"phrase"
            }
          
        },
        "functions": [
            {
              "gauss": {
                "pdate": {
                  "origin": "2019-07-01",
                  "scale": "180d",
                  "decay": 0.5,
                  "offset": "30d"
                }
              }
            },
            { 
              "script_score": {
                "script": "return doc ['org_name'].value == '国信证券' ? 1.9 : 1.0"
             }
            }
        ],
        
      "score_mode": "sum",
      "boost_mode": "multiply"
  }},
  "_source":["title","org_name","pdate"]
}

 

 

 

 

 

 

 

 

 

参考资料:https://blog.csdn.net/weixin_40341116/article/details/81003513

https://www.scienjus.com/elasticsearch-function-score-query/

posted @ 2019-07-08 14:15  myvic  阅读(2093)  评论(0编辑  收藏  举报