简体   繁体   English

弹性搜索parsing_exception用于增强查询

[英]elastic search parsing_exception for boost query

I'm trying to boost up the query using elastic search. 我正在尝试使用弹性搜索来增强查询。 Headlines that are published recently must be boosted up and should come on top. 最近发布的头条新闻必须得到加强,并且应该放在首位。 However, I have return the following code: 但是,我返回了以下代码:

{
"query": {
"function_score": {
"query": {
    "bool": {
            "must": {
                  "match": { 
                       "keywords": {
                          "query":"trump"
                                       }
                                  }
                             },
       "should": [
           { "match": {
                     "type": {
                             "query": "headline"
               }
           }}
       ]}},  

    "functions": [
        { "boost":  5 },
        {
        "gauss": {
        "versioncreated": {
        "origin": "now/d", 
        "scale": "50w", 
        "offset": "4w", 
        "decay": "0.5" 
}}}],
        "score_mode": "sum"
}
}}

I'm getting this error :- 我收到此错误消息:-

{
   "error": {
      "root_cause": [
     {
        "type": "parsing_exception",
        "reason": "no [score_function] registered for [params]",
        "line": 24,
        "col": 20
     }
      ],
      "type": "parsing_exception",
      "reason": "no [score_function] registered for [params]",
      "line": 24,
      "col": 20
   },
   "status": 400
}

You query is a bit wrong. 您的查询有点错误。 What do you want do by this? 您要做什么呢?

"functions": [
        { "boost":  5 },

If you want to boost it try to use this query 如果您想提升它,请尝试使用此查询

{
    "query": {
        "function_score": {
            "query": {
                "bool": {
                    "must": {
                        "match": {
                            "keywords": {
                                "query": "trump"
                            }
                        }
                    },
                    "should": [
                        {
                            "match": {
                                "type": {
                                    "query": "headline"
                                }
                            }
                        }
                    ]
                }
            },
            "functions": [
                {
                    "gauss": {
                        "versioncreated": {
                            "origin": "now/d",
                            "scale": "50w",
                            "offset": "4w",
                            "decay": "0.5"
                        }
                    }
                }
            ],
            "boost": 5,
            "score_mode": "sum"
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM