# Problem retrieving record with geo\_point in a subfield

**URL:** <https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363>\
**Category:** Elasticsearch\
**Created:** [October 15, 2012, 11:33pm UTC](https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363 "2012-10-15T23:33:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Jambon](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Martin\_Jambon](https://discuss.elastic.co/u/Martin_Jambon)\
**Post date:** [October 15, 2012, 11:33pm UTC](https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363/1 "2012-10-15T23:33:06Z")

</div>

Hello,

We are trying to index geographic coordinates present in a subfield, and  
can't make it work.

Here is the code to reproduce:

[https://gist.github.com/3896214](https://gist.github.com/3896214)

The last http request is the search query (on location.coord) that returns  
0 result.  
The query before that is on the field location2, which returns one result  
as expected.

Could be related to this issue:

[https://groups.google.com/forum/?fromgroups=#!topicsearchin/elasticsearch/global$20geo/elasticsearch/CCg58v2cFy4](https://groups.google.com/forum/?fromgroups=#!topicsearchin/elasticsearch/global%2420geo/elasticsearch/CCg58v2cFy4)

Any help would be great!

Thanks!

Martin

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 16, 2012, 12:23am UTC](https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363/2 "2012-10-16T00:23:38Z")

</div>

Hi Martin,

I did not run your test case but I'm wondering if after the doc insertion, you see something like "update mappings" in logs?  
When you get the mapping back, what can you see?

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 oct. 2012 à 01:33, Martin Jambon [mjambon@gmail.com](mailto:mjambon@gmail.com) a écrit :

Hello,

We are trying to index geographic coordinates present in a subfield, and can't make it work.

Here is the code to reproduce:

[https://gist.github.com/3896214](https://gist.github.com/3896214)

The last http request is the search query (on location.coord) that returns 0 result.  
The query before that is on the field location2, which returns one result as expected.

Could be related to this issue:

[https://groups.google.com/forum/?fromgroups=#!topicsearchin/elasticsearch/global$20geo/elasticsearch/CCg58v2cFy4](https://groups.google.com/forum/?fromgroups=#!topicsearchin/elasticsearch/global%2420geo/elasticsearch/CCg58v2cFy4)

Any help would be great!

Thanks!

Martin

--

--

---

<div class="post-metadata">

**Author:** ![Martin\_Jambon](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Martin\_Jambon](https://discuss.elastic.co/u/Martin_Jambon)\
**Post date:** [October 16, 2012, 1:03am UTC](https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363/3 "2012-10-16T01:03:54Z")

</div>

On 10/15/2012 05:23 PM, David Pilato wrote:

> Hi Martin,
> 
> I did not run your test case but I'm wondering if after the doc  
> insertion, you see something like "update mappings" in logs?

I see that:

[2012-10-15 17:43:36,704][INFO][cluster.metadata] [Wendigo] [test1350348216] creating index, cause [api], shards [5]/[1], mappings [doc]  
[2012-10-15 17:43:37,825][INFO][cluster.metadata] [Wendigo] [test1350348216] update\_mapping [doc] (dynamic)

> When you get the mapping back, what can you see?

A freshly created index gives me this:

$ curl -XGET "[http://127.0.0.1:9200/test1350348216/doc/\_mapping?pretty=true](http://127.0.0.1:9200/test1350348216/doc/_mapping?pretty=true)"  
{  
"doc" : {  
"properties" : {  
"id" : {  
"type" : "string",  
"index" : "not\_analyzed"  
},  
"location.coord" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
},  
"location2" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
}  
}  
}  
}

But after posting the first document, I get this:

$ curl -XGET '[http://127.0.0.1:9200/test1350348216/doc/\_mapping?pretty=true](http://127.0.0.1:9200/test1350348216/doc/_mapping?pretty=true)'  
{  
"doc" : {  
"properties" : {  
"id" : {  
"type" : "string",  
"index" : "not\_analyzed"  
},  
"location" : {  
"dynamic" : "true",  
"properties" : {  
"coord" : {  
"dynamic" : "true",  
"properties" : {  
"lat" : {  
"type" : "long",  
"ignore\_malformed" : false  
},  
"lon" : {  
"type" : "long",  
"ignore\_malformed" : false  
}  
}  
}  
}  
},  
"location.coord" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
},  
"location2" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
}  
}  
}

It looks as if the lack of declaration of the "location" field resulted in an interpretation that ignores the declaration of "location.coord" as soon as a document is posted.

Martin

> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 16 oct. 2012 à 01:33, Martin Jambon \<[mjambon@gmail.com](mailto:mjambon@gmail.com)  
> [mailto:mjambon@gmail.com](mailto:mjambon@gmail.com)\> a écrit :
> 
> Hello,
> 
> We are trying to index geographic coordinates present in a subfield, and  
> can't make it work.
> 
> Here is the code to reproduce:
> 
> [elasticsearch not indexing/finding geo\_point in a subfield · GitHub](https://gist.github.com/3896214)
> 
> The last http request is the search query (on location.coord) that  
> returns 0 result.  
> The query before that is on the field location2, which returns one  
> result as expected.
> 
> Could be related to this issue:
> 
> [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups=#!topicsearchin/elasticsearch/global$20geo/elasticsearch/CCg58v2cFy4)
> 
> Any help would be great!
> 
> Thanks!
> 
> Martin
> 
> --
> 
> --

--

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 16, 2012, 1:21am UTC](https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363/4 "2012-10-16T01:21:27Z")

</div>

Yes. That what I had in mind.  
I think that your mapping is incorrect.

You should define location as an object with a field coord: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/object-type.html)

My 2 cents

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 oct. 2012 à 03:03, Martin Jambon [mjambon@gmail.com](mailto:mjambon@gmail.com) a écrit :

On 10/15/2012 05:23 PM, David Pilato wrote:

> Hi Martin,
> 
> I did not run your test case but I'm wondering if after the doc  
> insertion, you see something like "update mappings" in logs?

I see that:

[2012-10-15 17:43:36,704][INFO][cluster.metadata] [Wendigo] [test1350348216] creating index, cause [api], shards [5]/[1], mappings [doc]  
[2012-10-15 17:43:37,825][INFO][cluster.metadata] [Wendigo] [test1350348216] update\_mapping [doc] (dynamic)

> When you get the mapping back, what can you see?

A freshly created index gives me this:

$ curl -XGET "[http://127.0.0.1:9200/test1350348216/doc/\_mapping?pretty=true](http://127.0.0.1:9200/test1350348216/doc/_mapping?pretty=true)"  
{  
"doc" : {  
"properties" : {  
"id" : {  
"type" : "string",  
"index" : "not\_analyzed"  
},  
"location.coord" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
},  
"location2" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
}  
}  
}  
}

But after posting the first document, I get this:

$ curl -XGET '[http://127.0.0.1:9200/test1350348216/doc/\_mapping?pretty=true](http://127.0.0.1:9200/test1350348216/doc/_mapping?pretty=true)'  
{  
"doc" : {  
"properties" : {  
"id" : {  
"type" : "string",  
"index" : "not\_analyzed"  
},  
"location" : {  
"dynamic" : "true",  
"properties" : {  
"coord" : {  
"dynamic" : "true",  
"properties" : {  
"lat" : {  
"type" : "long",  
"ignore\_malformed" : false  
},  
"lon" : {  
"type" : "long",  
"ignore\_malformed" : false  
}  
}  
}  
}  
},  
"location.coord" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
},  
"location2" : {  
"type" : "geo\_point",  
"lat\_lon" : true  
}  
}  
}

It looks as if the lack of declaration of the "location" field resulted in an interpretation that ignores the declaration of "location.coord" as soon as a document is posted.

Martin

> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 16 oct. 2012 à 01:33, Martin Jambon \<[mjambon@gmail.com](mailto:mjambon@gmail.com)  
> [mailto:mjambon@gmail.com](mailto:mjambon@gmail.com)\> a écrit :
> 
> Hello,
> 
> We are trying to index geographic coordinates present in a subfield, and  
> can't make it work.
> 
> Here is the code to reproduce:
> 
> [elasticsearch not indexing/finding geo\_point in a subfield · GitHub](https://gist.github.com/3896214)
> 
> The last http request is the search query (on location.coord) that  
> returns 0 result.  
> The query before that is on the field location2, which returns one  
> result as expected.
> 
> Could be related to this issue:
> 
> [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups=#!topicsearchin/elasticsearch/global$20geo/elasticsearch/CCg58v2cFy4)
> 
> Any help would be great!
> 
> Thanks!
> 
> Martin
> 
> --
> 
> --

--

--

---

<div class="post-metadata">

**Author:** ![Martin\_Jambon](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@Martin\_Jambon](https://discuss.elastic.co/u/Martin_Jambon)\
**Post date:** [October 16, 2012, 4:44pm UTC](https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363/5 "2012-10-16T16:44:45Z")

</div>

That's it!  
Thanks a lot.

The following creates an index with a proper mapping for location.coord  
of type {lat: ..., lon: ...}:

curl -XPUT [http://127.0.0.1:9200/$index](http://127.0.0.1:9200/$index) -d '{  
"mappings": {  
"doc": {  
"properties": {  
"id": { "type": "string", "index": "not\_analyzed" },  
"location": {  
"properties": {  
"coord": { "type": "geo\_point", "lat\_lon": true }  
}  
},  
"location2": { "type": "geo\_point", "lat\_lon": true }  
}  
}  
}  
}  
'

On 10/15/2012 06:21 PM, David Pilato wrote:

> Yes. That what I had in mind.  
> I think that your mapping is incorrect.
> 
> You should define location as an object with a field coord:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/object-type.html)
> 
> My 2 cents
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 16 oct. 2012 à 03:03, Martin Jambon \<[mjambon@gmail.com](mailto:mjambon@gmail.com)  
> [mailto:mjambon@gmail.com](mailto:mjambon@gmail.com)\> a écrit :
> 
> On 10/15/2012 05:23 PM, David Pilato wrote:
> 
> > Hi Martin,
> > 
> > I did not run your test case but I'm wondering if after the doc  
> > insertion, you see something like "update mappings" in logs?
> 
> I see that:
> 
> [2012-10-15 17:43:36,704][INFO][cluster.metadata] [Wendigo]  
> [test1350348216] creating index, cause [api], shards [5]/[1], mappings [doc]  
> [2012-10-15 17:43:37,825][INFO][cluster.metadata] [Wendigo]  
> [test1350348216] update\_mapping [doc] (dynamic)
> 
> > When you get the mapping back, what can you see?
> 
> A freshly created index gives me this:
> 
> $ curl -XGET "[http://127.0.0.1:9200/test1350348216/doc/\_mapping?pretty=true](http://127.0.0.1:9200/test1350348216/doc/_mapping?pretty=true)"  
> {  
> "doc" : {  
> "properties" : {  
> "id" : {  
> "type" : "string",  
> "index" : "not\_analyzed"  
> },  
> "location.coord" : {  
> "type" : "geo\_point",  
> "lat\_lon" : true  
> },  
> "location2" : {  
> "type" : "geo\_point",  
> "lat\_lon" : true  
> }  
> }  
> }  
> }
> 
> But after posting the first document, I get this:
> 
> $ curl -XGET '[http://127.0.0.1:9200/test1350348216/doc/\_mapping?pretty=true](http://127.0.0.1:9200/test1350348216/doc/_mapping?pretty=true)'  
> {  
> "doc" : {  
> "properties" : {  
> "id" : {  
> "type" : "string",  
> "index" : "not\_analyzed"  
> },  
> "location" : {  
> "dynamic" : "true",  
> "properties" : {  
> "coord" : {  
> "dynamic" : "true",  
> "properties" : {  
> "lat" : {  
> "type" : "long",  
> "ignore\_malformed" : false  
> },  
> "lon" : {  
> "type" : "long",  
> "ignore\_malformed" : false  
> }  
> }  
> }  
> }  
> },  
> "location.coord" : {  
> "type" : "geo\_point",  
> "lat\_lon" : true  
> },  
> "location2" : {  
> "type" : "geo\_point",  
> "lat\_lon" : true  
> }  
> }  
> }
> 
> It looks as if the lack of declaration of the "location" field resulted  
> in an interpretation that ignores the declaration of "location.coord" as  
> soon as a document is posted.
> 
> Martin
> 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 16 oct. 2012 à 01:33, Martin Jambon \<[mjambon@gmail.com](mailto:mjambon@gmail.com)  
> > [mailto:mjambon@gmail.com](mailto:mjambon@gmail.com)  
> > [mailto:mjambon@gmail.com](mailto:mjambon@gmail.com)\> a écrit :
> > 
> > Hello,
> > 
> > We are trying to index geographic coordinates present in a subfield, and  
> > can't make it work.
> > 
> > Here is the code to reproduce:
> > 
> > [elasticsearch not indexing/finding geo\_point in a subfield · GitHub](https://gist.github.com/3896214)
> > 
> > The last http request is the search query (on location.coord) that  
> > returns 0 result.  
> > The query before that is on the field location2, which returns one  
> > result as expected.
> > 
> > Could be related to this issue:
> > 
> > [Redirecting to Google Groups](https://groups.google.com/forum/?fromgroups=#!topicsearchin/elasticsearch/global$20geo/elasticsearch/CCg58v2cFy4)
> > 
> > Any help would be great!
> > 
> > Thanks!
> > 
> > Martin
> > 
> > --
> > 
> > --
> 
> --
> 
> --

--

---

<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:08am UTC](https://discuss.elastic.co/t/problem-retrieving-record-with-geo-point-in-a-subfield/9363/6 "2017-07-06T03:08:28Z")

</div>


