2016-08-16 7 views
0

私は2つのフィールドを有する弾性検索ドキュメント内のネストされたフィールドがあります:私はすべて欲しいblog1、blog2など弾性検索でネストされた文書をソート

blog = Nested(
    properties={ 
     'id': Integer(), 
     'rating': Integer() 
    } 
) 

アンES文書はブログのリストを持っているがblob.id = xの文書をそのblobに対応する評価フィールドでソートします。 ランク付けスクリプトを使用せずに弾力的な検索クエリでこれを実行することは可能ですか?ご意見をお聞かせください。

答えて

1

このような何かはあなたが必要なものを行う必要があります。

{ 
    "query": { 
    "nested": { 
     "path": "blog", 
     "query": { 
     "term": { 
      "blog.id": 123 
     } 
     } 
    } 
    }, 
    "sort": [ 
    { 
     "blog.rating": { 
     "order": "asc", 
     "nested_path": "blog", 
     "nested_filter": { 
      "term": { 
      "blog.id": 123 
      } 
     } 
     } 
    } 
    ] 
} 
関連する問題