# GeoPoint boost at mapping time

**URL:** <https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650>\
**Category:** Elasticsearch\
**Created:** [March 27, 2014, 4:24pm UTC](https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650 "2014-03-27T16:24:44Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kina\_Shah](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@Kina\_Shah](https://discuss.elastic.co/u/Kina_Shah)\
**Post date:** [March 27, 2014, 4:24pm UTC](https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650/1 "2014-03-27T16:24:44Z")

</div>

Hi,

What's the best way to give a GeoPoint boost at the mapping time?

I added a boost to List of GeoPoint field at the mapping time, but I don't  
see it doing anything with the score returned when I search on that  
geoPoint.

Here's how I added it in.  
.startObject()  
.startObject(TYPE)  
.startObject("properties")  
.startObject("sen\_location").field("type",  
"geo\_shape").field("geohash", true).field("geohash\_prefix",  
true).endObject()  
.startObject("fc\_location").field("type",  
"geo\_shape").field("geohash", true).field("geohash\_prefix",  
true).endObject()  
.startObject("tgt\_location").field("type",  
"geo\_shape").field("geohash", true).field("geohash\_prefix",  
true).endObject()

.startObject("corner\_location").field("type", "geo\_shape").field("geohash",  
true).field("lat\_lon", true).field("geohash\_prefix", true).endObject()

.startObject("senGeoPointLst").field("type", "geo\_point").field("geohash",  
true).field("lat\_lon", true).field("geohash\_prefix", true).field("boost",  
1).endObject()  
.startObject("fcGeoPointLst").field("type",  
"geo\_point").field("geohash", true).field("lat\_lon",  
true).field("geohash\_prefix", true).field("boost", 3).endObject()

.startObject("tgtGeoPointLst").field("type", "geo\_point").field("geohash",  
true).field("lat\_lon", true).field("geohash\_prefix", true).field("boost",  
2).endObject()

.startObject("cornerGeoPointLst").field("type",  
"geo\_point").field("geohash", true).field("lat\_lon",  
true).field("geohash\_prefix", true).field("boost", 4).endObject()  
.startObject("toaDTimeMin").field("type",  
"date").field("format", "date\_time").endObject()  
.startObject("toaDTimeMax").field("type",  
"date").field("format", "date\_time").endObject()  
.endObject()  
.endObject()  
.endObject();

Is this correct? Why its not working?

Thanks!

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/442d13f6-a916-4ce9-a94e-2f2bcefdba2c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/442d13f6-a916-4ce9-a94e-2f2bcefdba2c%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 27, 2014, 6:17pm UTC](https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650/2 "2014-03-27T18:17:35Z")

</div>

I am curious, what is your objective? Are you trying to do a geo search and  
rank locations that are closer in distance to a certain point higher in the  
hits result list?

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f3e341d6-1d84-41a4-8d38-1101996b4e07%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f3e341d6-1d84-41a4-8d38-1101996b4e07%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kina\_Shah](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@Kina\_Shah](https://discuss.elastic.co/u/Kina_Shah)\
**Post date:** [March 28, 2014, 2:59pm UTC](https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650/3 "2014-03-28T14:59:00Z")

</div>

Binh,

I have three different list of geopoints and I want to rank the document  
according to which set of geopoint matched the given geopoint within the  
radium given. So if you see I have given different boost number to each of  
these three geopoints.  
Thanks!

On Thursday, March 27, 2014 2:17:35 PM UTC-4, Binh Ly wrote:

> I am curious, what is your objective? Are you trying to do a geo search  
> and rank locations that are closer in distance to a certain point higher in  
> the hits result list?

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/bc76ed0e-52f8-4da7-94d2-5ab3cea713b0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/bc76ed0e-52f8-4da7-94d2-5ab3cea713b0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 28, 2014, 7:44pm UTC](https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650/4 "2014-03-28T19:44:40Z")

</div>

You can probably do this with a function\_score query. The idea is something  
like this:

localhost:9200/\_search  
{  
"query": {  
"function\_score": {  
"functions": [  
{  
"filter": {  
"geo\_distance" : {  
"distance" : "1km",  
"cornerGeoPointLst" : {  
"lat" : 40,  
"lon" : -70  
}  
}  
},  
"boost\_factor": 4  
},  
{  
"filter": {  
"geo\_distance" : {  
"distance" : "1km",  
"fcGeoPointLst" : {  
"lat" : 40,  
"lon" : -70  
}  
}  
},  
"boost\_factor": 3  
},  
{  
"filter": {  
"geo\_distance" : {  
"distance" : "1km",  
"tgtGeoPointLst" : {  
"lat" : 40,  
"lon" : -70  
}  
}  
},  
"boost\_factor": 2  
}  
]  
}  
}  
}

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a6ecf1f6-2217-4239-aad7-1052f42251ca%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a6ecf1f6-2217-4239-aad7-1052f42251ca%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Kina\_Shah](https://avatars.discourse-cdn.com/v4/letter/k/4bbf92/32.png) [@Kina\_Shah](https://discuss.elastic.co/u/Kina_Shah)\
**Post date:** [March 30, 2014, 8:32pm UTC](https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650/5 "2014-03-30T20:32:06Z")

</div>

Thanks, Binh! I did try that and that works. I am still curious to find out  
if there's any way to add the same during mapping time?

On Thursday, March 27, 2014 12:24:44 PM UTC-4, Kina Shah wrote:

> Hi,
> 
> What's the best way to give a GeoPoint boost at the mapping time?
> 
> I added a boost to List of GeoPoint field at the mapping time, but I don't  
> see it doing anything with the score returned when I search on that  
> geoPoint.
> 
> Here's how I added it in.  
> .startObject()  
> .startObject(TYPE)  
> .startObject("properties")  
> .startObject("sen\_location").field("type",  
> "geo\_shape").field("geohash", true).field("geohash\_prefix",  
> true).endObject()  
> .startObject("fc\_location").field("type",  
> "geo\_shape").field("geohash", true).field("geohash\_prefix",  
> true).endObject()  
> .startObject("tgt\_location").field("type",  
> "geo\_shape").field("geohash", true).field("geohash\_prefix",  
> true).endObject()
> 
> .startObject("corner\_location").field("type", "geo\_shape").field("geohash",  
> true).field("lat\_lon", true).field("geohash\_prefix", true).endObject()
> 
> .startObject("senGeoPointLst").field("type", "geo\_point").field("geohash",  
> true).field("lat\_lon", true).field("geohash\_prefix", true).field("boost",  
> 1).endObject()
> 
> .startObject("fcGeoPointLst").field("type", "geo\_point").field("geohash",  
> true).field("lat\_lon", true).field("geohash\_prefix", true).field("boost",  
> 3).endObject()
> 
> .startObject("tgtGeoPointLst").field("type", "geo\_point").field("geohash",  
> true).field("lat\_lon", true).field("geohash\_prefix", true).field("boost",  
> 2).endObject()
> 
> .startObject("cornerGeoPointLst").field("type",  
> "geo\_point").field("geohash", true).field("lat\_lon",  
> true).field("geohash\_prefix", true).field("boost", 4).endObject()  
> .startObject("toaDTimeMin").field("type",  
> "date").field("format", "date\_time").endObject()  
> .startObject("toaDTimeMax").field("type",  
> "date").field("format", "date\_time").endObject()  
> .endObject()  
> .endObject()  
> .endObject();
> 
> Is this correct? Why its not working?
> 
> Thanks!

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/68a4e3a2-7c39-44ca-b09c-c439ec1bf579%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/68a4e3a2-7c39-44ca-b09c-c439ec1bf579%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 1:39am UTC](https://discuss.elastic.co/t/geopoint-boost-at-mapping-time/16650/6 "2017-07-06T01:39:39Z")

</div>


