# Multiple location fields

**URL:** <https://discuss.elastic.co/t/multiple-location-fields/8267>\
**Category:** Elasticsearch\
**Created:** [June 29, 2012, 6:57pm UTC](https://discuss.elastic.co/t/multiple-location-fields/8267 "2012-06-29T18:57:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mario\_Menezes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mario_menezes/32/2812_2.png) [@Mario\_Menezes](https://discuss.elastic.co/u/Mario_Menezes)\
**Post date:** [June 29, 2012, 6:57pm UTC](https://discuss.elastic.co/t/multiple-location-fields/8267/1 "2012-06-29T18:57:45Z")

</div>

Hi,

I'm using django-haystack and ElasticSearch to index Stores.

Until now, each store had one lat,long coordinate pair; we had to change  
this to represent the fact that one store can deliver products to very  
different regions (disjunct) I've added up to ten locations (lat,long  
pairs) to then.

When using one location field everything was working fine and I got right  
results. Now, with multiple location fields, I can't get any results, not  
even the previuos one, for the same user and store coordinates.

My Index is as following:

curl -XGET [http://localhost:9200/stores/\_mapping?pretty=True](http://localhost:9200/stores/_mapping?pretty=True)  
{  
"stores" : {  
"modelresult" : {  
"properties" : {  
"django\_id" : {  
"type" : "string"  
},  
"location0" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location1" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location2" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location3" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location4" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location5" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location6" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location7" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location8" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"location9" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"text" : {  
"type" : "string",  
"analyzer" : "snowball",  
"store" : "yes",  
"term\_vector" : "with\_positions\_offsets"  
}  
}  
}  
}  
}

Then, I try to search my locations:

$ curl -XGET [http://localhost:9200/stores/modelresult/\_search?pretty=true](http://localhost:9200/stores/modelresult/_search?pretty=true)  
-d '{ "query" : { "match\_all": {} }, "filter" : {"geo\_distance" : {  
"distance" : "6km", "location0" : { "lat" : -23.5, "lon" : -46.5 } } } } '  
{  
"took" : 0,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 0,  
"max\_score" : null,  
"hits" : []  
}  
}

If I change my index and use only one location (this mapping):  
$ curl -XGET [http://localhost:9200/stoes/\_mapping?pretty=True](http://localhost:9200/stoes/_mapping?pretty=True)  
{  
"stores" : {  
"modelresult" : {  
"properties" : {  
"django\_ct" : {  
"type" : "string"  
},  
"django\_id" : {  
"type" : "string"  
},  
"id" : {  
"type" : "string"  
},  
"location0" : {  
"type" : "geo\_point",  
"store" : "yes"  
},  
"text" : {  
"type" : "string",  
"analyzer" : "snowball",  
"store" : "yes",  
"term\_vector" : "with\_positions\_offsets"  
}  
}  
}  
}  
}

Then, when I search, using the same query, I get:

$ curl -XGET [http://localhost:9200/stoes/modelresult/\_search?pretty=true](http://localhost:9200/stoes/modelresult/_search?pretty=true) -d  
'{ "query" : { "match\_all": {} }, "filter" : {"geo\_distance" : {  
"distance" : "6km", "location0" : { "lat" : -23.5, "lon" : -46.5 } } } } '  
{  
"took" : 3,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "stores",  
"\_type" : "modelresult",  
"\_id" : "store.store.128",  
"\_score" : 1.0, "\_source" : {"django\_ct": "store.store", "text":  
"Blah Blah", "django\_id": "128", "id": "store.store.128", "location0":  
"-23.5380755,-46.4663468"}  
} ]  
}  
}

```
 Can anyone tells me what I doing wrong? That is, why I'm not getting 

```

any results for the multiple location settings. I really need this feature.

```
 Of course, I rebuild the index after changing the location fields 

```

(removing or adding them).

```
 Thanks in advance.

 BTW, I'm pretty new to ElasticSearch.
```

---

<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:21am UTC](https://discuss.elastic.co/t/multiple-location-fields/8267/2 "2017-07-06T03:21:58Z")

</div>


