2016-08-22 8 views
1

距離で検索結果を並べ替えようとしています。私がしようとしたときしかし、私は次のエラーを取得する:距離で並べ替えるとエラーが発生する

{ 
    "error": { 
     "root_cause": [ 
     { 
      "type": "illegal_argument_exception", 
      "reason": "sort option [location] not supported" 
     } 
     ], 
     "type": "search_phase_execution_exception", 
     "reason": "all shards failed", 
     "phase": "query", 
     "grouped": true, 
     "failed_shards": [ 
     { 
      "shard": 0, 
      "index": "roeselaredev", 
      "node": "2UYlfd7sTd6qlJWgdK2wzQ", 
      "reason": { 
       "type": "illegal_argument_exception", 
       "reason": "sort option [location] not supported" 
      } 
     } 
     ] 
    }, 
    "status": 400 
} 

私が送信されたクエリは次のようになります。私は手紙にマニュアルの指示に従っ知る限り

GET _search 
{ 
    "query": { 
     "match_all": [] 
    }, 
    "sort": [ 

     { 
      "geo_distance": { 
       "location": { 
        "lat": 50.9436034, 
        "long": 3.1242917 
       }, 
       "order":"asc", 
       "unit":"km", 
       "distance_type":"plane" 
      } 
     }, 
     { 
      "_score": { 
       "order":"desc" 
      }   
     } 
    ] 
} 

。私は不正なクエリ結果を取得していません。私はちょうど距離によるソートオプションではサポートされていない結果を得ています。私は間違って何をしているかに関する任意のアイデアですか?

+0

? – Sylwit

+0

geo_distanceはフィルタの名前です。マッピングされていません。 ロケーションは次のようにマッピングされます: 'location:{タイプ:geo_point、property_path:esGetLocation}' esGetLocationメソッドは、latとlongを含む文字列を返します(コンマで区切ります) –

答えて

1

クエリdslは無効です.OPはほぼ正解ですが、アンダースコアがありません。

距離によるソートは_geo_distanceであり、geo_distanceではありません。

例: `geo_distance`をマッピングする方法は

GET _search 
{ 
    "query": { 
     "match_all": [] 
    }, 
    "sort": [ 

     { 
      "_geo_distance": { 
       "location": { 
        "lat": 50.9436034, 
        "long": 3.1242917 
       }, 
       "order":"asc", 
       "unit":"km", 
       "distance_type":"plane" 
      } 
     }, 
     { 
      "_score": { 
       "order":"desc" 
      }   
     } 
    ] 
} 
+0

gah:p非常に義務付けられています! –

関連する問題