2017-07-26 11 views
0

私はElasticsearchを初めて利用しています。私はINDEX &を作成しました。いくつかの文書はCURLコマンドに従っています。あなたはカールのコマンドが表示されます場合はElasticsearchから一意のジオコードを取得する方法は?

curl -XPUT 'localhost:9200/museums?pretty' -H 'Content-Type: application/json' -d' 
{ 
    "mappings": { 
     "doc": { 
      "properties": { 
       "location": { 
        "type": "geo_point" 
       } 
      } 
     } 
    } 
} 
' 
curl -XPOST 'localhost:9200/museums/doc/_bulk?refresh&pretty' -H 'Content-Type: application/json' -d' 
{"index":{"_id":1}} 
{"location": "52.374081,4.912350", "name": "NEMO Science Museum"} 
{"index":{"_id":2}} 
{"location": "52.369219,4.901618", "name": "Museum Het Rembrandthuis"} 
{"index":{"_id":3}} 
{"location": "52.371667,4.914722", "name": "Nederlands Scheepvaartmuseum"} 
{"index":{"_id":4}} 
{"location": "51.222900,4.405200", "name": "Letterenhuis"} 
{"index":{"_id":5}} 
{"location": "48.861111,2.336389", "name": "Musée du Louvre"} 
{"index":{"_id":6}} 
{"location": "48.860000,2.327000", "name": "Musée d\u0027Orsay"} 
{"index":{"_id":7}} 
{"location": "52.374081,4.912350", "name": "NEMO7 Science Museum"} 
{"index":{"_id":8}} 
{"location": "52.369219,4.901618", "name": "Museum8 Het Rembrandthuis"} 
{"index":{"_id":9}} 
{"location": "52.371667,4.914722", "name": "Nederlands9 Scheepvaartmuseum"} 
{"index":{"_id":10}} 
{"location": "51.222900,4.405200", "name": "Letterenhuis10"} 
{"index":{"_id":11}} 
{"location": "48.861111,2.336389", "name": "Musée11 du Louvre"} 
{"index":{"_id":12}} 
{"location": "48.860000,2.327000", "name": "Musée12 d\u0027Orsay"} 
' 

私はまた、これらを挿入し、いくつかの重複文書&を作りました。今、私はユニークなGEOコード&がSORT(ASC)を適用しているすべてのドキュメントを取得したいと思っています。

次のように1つのサンプルのCURLコマンドがあります。

しかし、それにはRANGEが使用されます。ユニークなGEOコード& SORTだけを降順で取得したいだけです。私もグーグルで探せましたが、ユニークなドキュメントを取得しようとしているものは、TEXT/NUMERICタイプのドキュメントだけです。 GEO CODESタイプの文書ではありません。

助けが必要です。

答えて

0

試してみてください。

curl -XPOST 'localhost:9200/museums/_search?size=0&pretty' -H 'Content-Type: application/json' -d' {返信用

"size" : 0, 
    "aggs": { 
      "distinct_geo_distance" : { 
       "cardinality" : { 
       "field" : "location" 
       } 
      } 
    } 
} 
+0

感謝。それは別個の文書数を返す。私の場合は6です。しかし、私は文書のデータも必要とします。 – mi6crazyheart

関連する問題