# Problems with Geo Mapping

**URL:** <https://discuss.elastic.co/t/problems-with-geo-mapping/6123>\
**Category:** Elasticsearch\
**Created:** [December 12, 2011, 12:04am UTC](https://discuss.elastic.co/t/problems-with-geo-mapping/6123 "2011-12-12T00:04:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tiftif](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tiftif](https://discuss.elastic.co/u/tiftif)\
**Post date:** [December 12, 2011, 12:04am UTC](https://discuss.elastic.co/t/problems-with-geo-mapping/6123/1 "2011-12-12T00:04:00Z")

</div>

I am trying to map the geo location data of tweets but I keep getting  
errors...

1. curl -XPUT '[http://localhost:9200/media/](http://localhost:9200/media/)'

2. curl -XPUT '[http://localhost:9200/media/twitter/\_mapping](http://localhost:9200/media/twitter/_mapping)' -d '  
{  
"geo" : {  
"properties" : {  
"location" : {  
"type" : "geo\_point"  
}  
}  
}  
}  
'

3. curl -XPUT '[http://localhost:9200/media/twitter/1](http://localhost:9200/media/twitter/1)' -d '  
{  
"geo" : {  
"location" : {  
"lat" : 40.12,  
"lon" : -71.34  
}  
},  
"tags" : ["food", "family"],  
"text" : "my favorite family restaurant"  
}'

4. curl -XGET '[http://localhost:9200/media/twitter/\_search](http://localhost:9200/media/twitter/_search)' -d  
'{ "query" : {  
"filtered" : {  
"query" : {  
"field" : { "text" : "restaurant" }  
},  
"filter" : {  
"geo\_distance" : {  
"distance" : "200km",  
"geo.location" : {  
"lat" : 40,  
"lon" : -70  
}  
}  
}  
}  
}}'

5. I get an exception that contains: "failed to find geo\_point field  
[geo.location]];"

What am I doing wrong? ☹

---

<div class="post-metadata">

**Author:** ![tiftif](https://avatars.discourse-cdn.com/v4/letter/t/90ced4/32.png) [@tiftif](https://discuss.elastic.co/u/tiftif)\
**Post date:** [December 12, 2011, 12:48am UTC](https://discuss.elastic.co/t/problems-with-geo-mapping/6123/2 "2011-12-12T00:48:00Z")

</div>

Okay, I think I figured out what I was doing wrong. I guess I need to  
have a single root element that should probably be the same name as  
the type itself.

Here's what works:

1. curl -XDELETE '[http://localhost:9200/media](http://localhost:9200/media)'

2. curl -XPUT '[http://localhost:9200/media/](http://localhost:9200/media/)'

3. curl -XPUT '[http://localhost:9200/media/twitter/\_mapping](http://localhost:9200/media/twitter/_mapping)' -d '  
{  
"twitter" : {  
"properties" : {  
"geo" : {  
"type" : "object",  
"properties" : {  
"location" : {  
"type" : "geo\_point"  
}  
}  
}  
}  
}  
}  
'

4. curl -XPUT '[http://localhost:9200/media/twitter/1](http://localhost:9200/media/twitter/1)' -d '  
{  
"twitter" : {  
"geo" : {  
"location" : {  
"lat" : 40.12,  
"lon" : -71.34  
},  
"tags" : ["food", "family"],  
"text" : "my favorite family restaurant"  
}  
}  
}'

5. curl -XGET '[http://localhost:9200/media/twitter/\_search](http://localhost:9200/media/twitter/_search)' -d  
'{ "query" : {  
"filtered" : {  
"query" : {  
"field" : { "text" : "restaurant" }  
},  
"filter" : {  
"geo\_distance" : {  
"distance" : "200km",  
"geo.location" : {  
"lat" : 40,  
"lon" : -70  
}  
}  
}  
}  
}}'

On Dec 11, 7:04 pm, tiftif [atifsyed...@gmail.com](mailto:atifsyed...@gmail.com) wrote:

> I am trying to map the geo location data of tweets but I keep getting  
> errors...
> 
> 1. curl -XPUT '[http://localhost:9200/media/](http://localhost:9200/media/)'
> 
> 2. curl -XPUT '[http://localhost:9200/media/twitter/\_mapping'-d](http://localhost:9200/media/twitter/_mapping'-d) '  
> {  
> "geo" : {  
> "properties" : {  
> "location" : {  
> "type" : "geo\_point"  
> }  
> }  
> }}
> 
> '
> 
> 1. curl -XPUT '[http://localhost:9200/media/twitter/1'-d](http://localhost:9200/media/twitter/1'-d) '  
> {  
> "geo" : {  
> "location" : {  
> "lat" : 40.12,  
> "lon" : -71.34  
> }  
> },  
> "tags" : ["food", "family"],  
> "text" : "my favorite family restaurant"
> 
> }'
> 
> 1. curl -XGET '[http://localhost:9200/media/twitter/\_search'-d](http://localhost:9200/media/twitter/_search'-d)  
> '{ "query" : {  
> "filtered" : {  
> "query" : {  
> "field" : { "text" : "restaurant" }  
> },  
> "filter" : {  
> "geo\_distance" : {  
> "distance" : "200km",  
> "geo.location" : {  
> "lat" : 40,  
> "lon" : -70  
> }  
> }  
> }  
> }
> 
> }}'
> 
> 1. I get an exception that contains: "failed to find geo\_point field  
> [geo.location]];"
> 
> What am I doing wrong? ☹

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 12, 2011, 12:56pm UTC](https://discuss.elastic.co/t/problems-with-geo-mapping/6123/3 "2011-12-12T12:56:13Z")

</div>

Yes, thats the way to do it (sorry for the late response...)

On Mon, Dec 12, 2011 at 2:48 AM, tiftif [atifsyedali@gmail.com](mailto:atifsyedali@gmail.com) wrote:

> Okay, I think I figured out what I was doing wrong. I guess I need to  
> have a single root element that should probably be the same name as  
> the type itself.
> 
> Here's what works:
> 
> 1. curl -XDELETE '[http://localhost:9200/media](http://localhost:9200/media)'
> 
> 2. curl -XPUT '[http://localhost:9200/media/](http://localhost:9200/media/)'
> 
> 3. curl -XPUT '[http://localhost:9200/media/twitter/\_mapping](http://localhost:9200/media/twitter/_mapping)' -d '  
> {  
> "twitter" : {  
> "properties" : {  
> "geo" : {  
> "type" : "object",  
> "properties" : {  
> "location" : {  
> "type" : "geo\_point"  
> }  
> }  
> }  
> }  
> }  
> }  
> '
> 
> 4. curl -XPUT '[http://localhost:9200/media/twitter/1](http://localhost:9200/media/twitter/1)' -d '  
> {  
> "twitter" : {  
> "geo" : {  
> "location" : {  
> "lat" : 40.12,  
> "lon" : -71.34  
> },  
> "tags" : ["food", "family"],  
> "text" : "my favorite family restaurant"  
> }  
> }  
> }'
> 
> 5. curl -XGET '[http://localhost:9200/media/twitter/\_search](http://localhost:9200/media/twitter/_search)' -d  
> '{ "query" : {  
> "filtered" : {  
> "query" : {  
> "field" : { "text" : "restaurant" }  
> },  
> "filter" : {  
> "geo\_distance" : {  
> "distance" : "200km",  
> "geo.location" : {  
> "lat" : 40,  
> "lon" : -70  
> }  
> }  
> }  
> }  
> }}'
> 
> On Dec 11, 7:04 pm, tiftif [atifsyed...@gmail.com](mailto:atifsyed...@gmail.com) wrote:
> 
> > I am trying to map the geo location data of tweets but I keep getting  
> > errors...
> > 
> > 1. curl -XPUT '[http://localhost:9200/media/](http://localhost:9200/media/)'
> > 
> > 2. curl -XPUT '[http://localhost:9200/media/twitter/\_mapping'-d](http://localhost:9200/media/twitter/_mapping'-d) '  
> > {  
> > "geo" : {  
> > "properties" : {  
> > "location" : {  
> > "type" : "geo\_point"  
> > }  
> > }  
> > }}
> > 
> > '
> > 
> > 1. curl -XPUT '[http://localhost:9200/media/twitter/1'-d](http://localhost:9200/media/twitter/1'-d) '  
> > {  
> > "geo" : {  
> > "location" : {  
> > "lat" : 40.12,  
> > "lon" : -71.34  
> > }  
> > },  
> > "tags" : ["food", "family"],  
> > "text" : "my favorite family restaurant"
> > 
> > }'
> > 
> > 1. curl -XGET '[http://localhost:9200/media/twitter/\_search'-d](http://localhost:9200/media/twitter/_search'-d)  
> > '{ "query" : {  
> > "filtered" : {  
> > "query" : {  
> > "field" : { "text" : "restaurant" }  
> > },  
> > "filter" : {  
> > "geo\_distance" : {  
> > "distance" : "200km",  
> > "geo.location" : {  
> > "lat" : 40,  
> > "lon" : -70  
> > }  
> > }  
> > }  
> > }
> > 
> > }}'
> > 
> > 1. I get an exception that contains: "failed to find geo\_point field  
> > [geo.location]];"
> > 
> > What am I doing wrong? ☹

---

<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, 3:45am UTC](https://discuss.elastic.co/t/problems-with-geo-mapping/6123/4 "2017-07-06T03:45:41Z")

</div>

Closed on July 6, 2017, 3:45am UTC


