ElasticSearch衰减最小值

时间:2019-03-14 01:01:41

标签: elasticsearch

按如下所述使用衰减函数:https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-decay

GET /_search
{
    "query": {
        "function_score": {
            "gauss": {
                "date": {
                      "origin": "2013-09-17", 
                      "scale": "10d",
                      "offset": "5d", 
                      "decay" : 0.5 
                }
            }
        }
    }
}

是否可以设置最大衰减?基本上,即使该项目使用了1年,它也只会衰减0.25。

1 个答案:

答案 0 :(得分:1)

您可以使用以下内容:

/***********************************************************************/

int main(int argc, char **argv)
{
XPRBvar xs;               /* Number of small chess sets to make */
XPRBvar xl;               /* Number of large chess sets to make */
XPRBprob p("Chess");      /* Initialize a new problem in BCL */

                          /****VARIABLES****/
xs = p.newVar("xs");
xl = p.newVar("xl");

/****OBJECTIVE****/
p.setObj(p.newCtr("OBJ", 5 * xs + 20 * xl)); /* Define & set the obj. 
function */

                                             /****CONSTRAINTS****/
                                             /* Define the constraint 
3*xs + 2*xl <= 400 */
p.newCtr("mc_time", 3 * xs + 2 * xl <= 400);

/* Define the constraint xs + 3*xl <= 200 */
p.newCtr("wood", xs + 3 * xl <= 200);

/****SOLVING****/
p.lpOptimize("");         /* Solve the LP-problem */

 return 0;
}