Thank you Alexander,
I had managed to figure out on my own that I can use geo shapes to achieve
querying for intersecting objects. Now, I am wondering how costly it would
be to index geo spatial data with elasticsearch given the fact that I need
high precision. I wonder if anyone could point me to some stats so I do not
have to explore it on my own.
I include the steps that helped me find the answer to my original question
in case someone else faces the same problem.
The data don't make much sense, I used both points and shapes to explore
their differences.
--Panagiotis
- create index and mapping
curl -XPUT 'localhost:9200/locations_index'
curl -XPUT 'http://localhost:9200/locations_index/location/_mapping' -d '
{
"location":{
"properties":{
"longId":{
"type":"long",
"store":"yes"
},
"id":{
"include_in_all":"false",
"index":"not_analyzed",
"type":"string",
"store":"yes"
},
"pin":{
"type":"geo_point",
"store":"yes"
},
"shape": {
"type": "geo_shape",
"tree": "quadtree",
"precision": "1m"
}
}
}
}'
- populate index
curl -XPUT 'http://localhost:9200/locations_index/location/rd_1700' -d '
{
"longId": 1700,
"id": "id_1700",
"pin": {
"lat": 40.740000000000002,
"lon": 73.989999999999995
},
"shape" : {
"type" : "polygon",
"coordinates" : [
[ [50.0, 0.0], [51.0, 0.0], [51.0, 1.0], [50.0, 1.0], [50.0,
0.0] ]
]
}
}'
curl -XPUT 'http://localhost:9200/locations_index/location/rd_1701' -d '
{
"longId": 1701,
"id": "id_1701",
"pin": {
"lat": 30.740000000000002,
"lon": 65.989999999999995
},
"shape" : {
"type" : "polygon",
"coordinates" : [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0],
[100.0, 0.0] ]
]
}
}
}'
- run a geo distance query (on geo_points)
curl -XGET 'http://localhost:9200/locations_index/location/_search' -d '
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_distance": {
"distance": "10km",
"pin": {
"lat": 40.74,
"lon": 73.99
}
}
}
}
}
}'
- run a geo polygon query (on geo_points)
curl -XGET 'http://localhost:9200/locations_index/location/_search' -d '
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter" : {
"geo_polygon" : {
"pin" : {
"points" : [
{"lat" : 45, "lon" : 70},
{"lat" : 30, "lon" : 60},
{"lat" : 20, "lon" : 90}
]
}
}
}
}
}
}'
- run a geo shape query (on geo_shapes)
curl -XGET 'http://localhost:9200/locations_index/location/_search' -d '
{
"from": 0,
"size": 10,
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"geo_shape": {
"shape": {
"shape": {
"type" : "polygon",
"coordinates" : [
[ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0],
[100.0, 1.0], [100.0, 0.0] ]
]
}
}
}
}
}
}
}'
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.