2017-02-10 119 views
0

我试图提高查询使用弹性搜索。最近出版的头条新闻必须提高,应该位列榜首。不过,我有返回下面的代码:弹性搜索parsing_exception升压查询

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

我得到这个错误: -

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

回答

0

您查询是有点不对劲。你想用这个做什么?

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

如果你想提高它试图通过5 _score + 5的每个标题结果使用此查询

{ 
    "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" 
     } 
    } 
} 
+0

这将提振_score –