# Nested geo-point mapping and querying

**URL:** <https://discuss.elastic.co/t/nested-geo-point-mapping-and-querying/9392>\
**Category:** Elasticsearch\
**Created:** [October 17, 2012, 2:40pm UTC](https://discuss.elastic.co/t/nested-geo-point-mapping-and-querying/9392 "2012-10-17T14:40:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmarchand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fmarchand/32/852_2.png) [@fmarchand](https://discuss.elastic.co/u/fmarchand)\
**Post date:** [October 17, 2012, 2:40pm UTC](https://discuss.elastic.co/t/nested-geo-point-mapping-and-querying/9392/1 "2012-10-17T14:40:51Z")

</div>

I have indexed document in my elastic search. Here is the mapping :

{  
"offers": {  
"offer": {  
"properties": {  
"company": {  
"dynamic": "true",  
"properties": {  
"id": {  
"type": "string"  
},  
"name": {  
"type": "string"  
}  
}  
},  
"description": {  
"type": "string"  
},  
_"location": {_

- "type": "nested",\*
- "properties": {\*
- "id": {\*
- "type": "string"\*
- },\*
- "name": {\*
- "type": "string"\*
- },\*
- "pin": {\*
- "type": "geo\_point"\*
- }\*
- }\*
- }\*,  
"publicationDate": {  
"type": "long",  
"ignore\_malformed": false  
},  
"title": {  
"type": "string"  
}  
}  
}  
}  
}

My problem is with the location/pin field. I would like to run a query like  
this :  
{  
"query": {  
"match\_all" : { }

```
},
"filter" : {
        "geo_distance" : {
            "distance" : "5000km",
            "location.pin" : {"lat":45.75,"lon":4.85}
        }
    }

```

}

I have no hits ... I'm missing something or I don't use nested type  
correctly ... or ... I don't know 🙂

Can I have some help about this ?

--

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [October 17, 2012, 2:46pm UTC](https://discuss.elastic.co/t/nested-geo-point-mapping-and-querying/9392/2 "2012-10-17T14:46:00Z")

</div>

> I have no hits ... I'm missing something or I don't use nested type  
> correctly ... or ... I don't know 🙂

Nested objects need to be queried with nested query or nested filter

clint

> Can I have some help about this ?
> 
> --

--

---

<div class="post-metadata">

**Author:** ![fmarchand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fmarchand/32/852_2.png) [@fmarchand](https://discuss.elastic.co/u/fmarchand)\
**Post date:** [October 17, 2012, 2:51pm UTC](https://discuss.elastic.co/t/nested-geo-point-mapping-and-querying/9392/3 "2012-10-17T14:51:32Z")

</div>

ok ... removing \*"type": "nested" \*solved the pb. I was not using nested  
for the right thing ....  
thx

On Wednesday, October 17, 2012 4:40:52 PM UTC+2, fmarchand wrote:

> I have indexed document in my Elasticsearch. Here is the mapping :
> 
> {  
> "offers": {  
> "offer": {  
> "properties": {  
> "company": {  
> "dynamic": "true",  
> "properties": {  
> "id": {  
> "type": "string"  
> },  
> "name": {  
> "type": "string"  
> }  
> }  
> },  
> "description": {  
> "type": "string"  
> },  
> _"location": {_
> 
> - "type": "nested",\*
> - "properties": {\*
> - "id": {\*
> - "type": "string"\*
> - },\*
> - "name": {\*
> - "type": "string"\*
> - },\*
> - "pin": {\*
> - "type": "geo\_point"\*
> - }\*
> - }\*
> - }\*,  
> "publicationDate": {  
> "type": "long",  
> "ignore\_malformed": false  
> },  
> "title": {  
> "type": "string"  
> }  
> }  
> }  
> }  
> }
> 
> My problem is with the location/pin field. I would like to run a query  
> like this :  
> {  
> "query": {  
> "match\_all" : { }
> 
> ```
> },
> "filter" : {
> "geo_distance" : {
> "distance" : "5000km",
> "location.pin" : {"lat":45.75,"lon":4.85}
> }
> }
> 
> ```
> 
> }
> 
> I have no hits ... I'm missing something or I don't use nested type  
> correctly ... or ... I don't know 🙂
> 
> Can I have some help about this ?

--

---

<div class="post-metadata">

**Author:** ![fmarchand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/fmarchand/32/852_2.png) [@fmarchand](https://discuss.elastic.co/u/fmarchand)\
**Post date:** [October 17, 2012, 2:54pm UTC](https://discuss.elastic.co/t/nested-geo-point-mapping-and-querying/9392/4 "2012-10-17T14:54:48Z")

</div>

Yes, you're right 🙂

Is nested query used for objects in an array ? like a query on a list of  
objects ?

I will try to read more about it ...

Thx !

On Wednesday, October 17, 2012 4:46:30 PM UTC+2, Clinton Gormley wrote:

> > I have no hits ... I'm missing something or I don't use nested type  
> > correctly ... or ... I don't know 🙂
> 
> Nested objects need to be queried with nested query or nested filter
> 
> clint
> 
> > Can I have some help about this ?
> > 
> > --

--

---

<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/nested-geo-point-mapping-and-querying/9392/5 "2017-07-06T03:08:17Z")

</div>


