# Running a geospatial query

**URL:** <https://discuss.elastic.co/t/running-a-geospatial-query/13762>\
**Category:** Elasticsearch\
**Created:** [September 26, 2013, 6:39am UTC](https://discuss.elastic.co/t/running-a-geospatial-query/13762 "2013-09-26T06:39:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gerson\_Galang1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/gerson_galang1/32/2036_2.png) [@Gerson\_Galang1](https://discuss.elastic.co/u/Gerson_Galang1)\
**Post date:** [September 26, 2013, 6:39am UTC](https://discuss.elastic.co/t/running-a-geospatial-query/13762/1 "2013-09-26T06:39:59Z")

</div>

Hi,

I've been trying to get this simple example of running spatial query with  
the data I added into ES but couldn't get anything back.Both the intersects  
and within return zero hits. Is there anything I am missing?

curl -XDELETE '[http://localhost:9200/\_all/](http://localhost:9200/_all/)'

curl -XPUT 'localhost:9200/locations\_index'

curl -XPUT '[http://localhost:9200/locations\_index/dataset/\_mapping](http://localhost:9200/locations_index/dataset/_mapping)' -d '  
{  
"dataset":{  
"properties":{  
"longId":{  
"type":"long",  
"store":"yes"  
},  
"id":{  
"include\_in\_all":"false",  
"index":"not\_analyzed",  
"type":"string",  
"store":"yes"  
},  
"location":{  
"type":"geo\_shape",  
"tree":"quadtree",  
"precision":"1m",  
"store":"yes"  
}  
}  
}  
}'

curl -XPUT '[http://localhost:9200/locations\_index/dataset/rd\_1700](http://localhost:9200/locations_index/dataset/rd_1700)' -d '  
{  
"longId": 1700,  
"id": "id\_1700",  
"location": {  
"type":"envelope",  
"coordinates":[[96.8, -43.7],[159.1, -9.1]]  
}  
}'

curl -XGET '  
[http://localhost:9200/locations\_index/dataset/\_search?pretty=true](http://localhost:9200/locations_index/dataset/_search?pretty=true)' -d '{  
"query": {  
"geo\_shape" : {  
"location" : {  
"shape":{  
"type":"envelope",  
"coordinates" : [[96.8, -43.7],[159.1, -9.1]]  
},  
"relation":"intersects"  
}  
}  
}  
}  
'

curl -XGET '  
[http://localhost:9200/locations\_index/dataset/\_search?pretty=true](http://localhost:9200/locations_index/dataset/_search?pretty=true)' -d '{  
"query": {  
"geo\_shape" : {  
"location" : {  
"shape":{  
"type":"envelope",  
"coordinates" : [[95.0, -45.7],[160.1, -8.1]]  
},  
"relation":"within"  
}  
}  
}  
}  
'

Thanks,  
Gerson

--  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:14am UTC](https://discuss.elastic.co/t/running-a-geospatial-query/13762/2 "2017-07-06T02:14:38Z")

</div>


