2017-02-10 18 views
0

私は弾性検索を使用してクエリを強化しようとしています。最近公表された見出しは増強されなければなりません。しかし、私は次のコードを返します:弾性検索parsing_exceptionがboostクエリ

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

このクエリ

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

を使用しようと、それを後押ししたい場合は、各見出しの結果のために5 _score + 5で_scoreを後押しします –