0

特定のデータ ポイントから x km 以内にあるすべてのアドレスを検索するために、MySQL テーブルでインデックス化された Elasticsearch を使用しようとしています。次のようにテーブルにインデックスを付けました。

{
  "type": "jdbc",
  "jdbc": {
       "strategy": "simple",
       "url": "jdbc:mysql://hostname/databasename",
       "user": "username",
       "password": "password",
       "sql": "SELECT name,address1,city,state,zip,lat as `location.lat`,lng as `location.lon` FROM addresses",
       "poll": "24h",
       "max_retries": 3,
       "max_retries_wait": "10s",
       "index" : "teststores",
       "type" : "providers"
   },
   "index": {
       "index": "addressindex",
       "autocommit": "true",
       "type": "mysql",
       "bulk_size": 100,
       "type_mapping": {
           "location_mapping" : { 
                "properties" : {
                    "pin" : {
                        "type" : "geo_point"
                    }
                }       
            }
        }
   }
}

インデックス付きデータの例は次のとおりです。

"_index": "teststores",
"_type": "providers",
"_id": "Rue2Yxo7SSa_mi5-AzRycA",
"_score": 1,
"_source": {
    "zip": "10003",
    "name": "I Salon",
    "state": "NY",
    "address1": "150 East 14th Street",
    "location":{
                "lat": 40.7337,
                "lon": -73.9881
               },
    "city": "New York"
}

次のクエリを調整して、距離の計算に緯度と経度を使用したいと考えています。

{ 
  "query": {
       "filtered": {
       "query": {
          "match_all": {
           }
        },
        "filter": {
           "geo_distance" : {
               "distance" : "2km",
               "pin.location" : {
                    "lat" : 40.686511,
                    "lon" : -73.986574
                }
            }
        }
     }
  },
}

これを調整して距離を機能させ、すべての住所を x キロメートル以内に取得するにはどうすればよいですか?

4

0 に答える 0