2017-03-12 11 views
0

findというインデックスとsongというタイプのインデックスがあります。 ソング型構造:ので、複数の曲の弾性検索ブースト

"_index": "find", 
    "_type": "song", 
    "_id": "192108", 
    "_source": { 
     "id": 192108,   
     "artist": "Melanie", 
     "title": "Dark Night", 
     "lyrics": "Hot air hangs like a dead man\nFrom a white oak tree", 
     "downloadCount": 234 
    } 

は多分同じフィールド値を持っているので、私は、このようなdownloadCountとして人気のフィールドで結果を後押しする必要があります。

私は以下のクエリをdownloadCountで最適化するように変更できますか?

GET /search/song/_search 
{ 
    "query": { 
     "multi_match": { 
      "query": "like a dead hangs", 
      "type": "most_fields", 
      "fields": ["artist","title","lyrics"], 
      "operator": "or" 
     } 
    } 
} 
+0

多分との間に2つのインデックス付きの曲は、曲は少し最高のスコアを持っていますが、他の曲は、ユーザーの間で最も人気があったと多くのダウンロードを持っています。 scoreとdownloadCountのフィールド値の組み合わせで結果をランク付けする必要があります。 – Mehmed

答えて

0

で結果を後押しするelastic_searchのfield_value_factor機能を使用することができます。関数スコアクエリは、script_score関数を介してドキュメントフィールドに基づいてドキュメントをスコアリングするためのAPIを提供します。

{ 
    "query": { 
     "function_score": { 
      "query": { 
       "bool": { 
        "must": [{ 
         "term": { 
          "you_filter_field": { 
           "value": "VALUE" 
          } 
         } 
        }] 
       } 
      }, 
      "functions": [{ 
       "script_score": { 
        "script": "doc['downloadCount'].value" 
       } 
      }] 
     } 
    } 
} 

おかげ