# Boosting for a number near X

**URL:** https://discuss.elastic.co/t/boosting-for-a-number-near-x/17026
**Category:** Elasticsearch
**Created:** [April 15, 2014, 1:18pm UTC](https://discuss.elastic.co/t/boosting-for-a-number-near-x/17026 "2014-04-15T13:18:17Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Guy\_Bowden](https://avatars.discourse-cdn.com/v4/letter/g/9de0a6/32.png) [@Guy\_Bowden](https://discuss.elastic.co/u/Guy_Bowden)
#### Post date: [April 15, 2014, 1:18pm UTC](https://discuss.elastic.co/t/boosting-for-a-number-near-x/17026/1 "2014-04-15T13:18:17Z")

</div>

Hi,

I have documents (accommodations) stored with a numeric attribute - "number  
of beds"

I'd like to be able to boost by a certain amount if that number is close to  
a search query.

e.g. prefer documents with a number of beds close to what is being searched  
for.

This will be added to the rest of the search criteria - is there a way to  
do this? I can filter by a number within a range, but would like the  
results returned to take some ordering from the closeness of the number  
searched for.

Thanks  
Guy

--  
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/e4e54a0c-16af-4c55-a01e-f074d066fc01%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e4e54a0c-16af-4c55-a01e-f074d066fc01%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Hannes\_Korte](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hannes_korte/32/909_2.png) [@Hannes\_Korte](https://discuss.elastic.co/u/Hannes_Korte)
#### Post date: [April 15, 2014, 1:45pm UTC](https://discuss.elastic.co/t/boosting-for-a-number-near-x/17026/2 "2014-04-15T13:45:09Z")

</div>

Hi Guy,

sounds like you are looking for the function score query:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

And there maybe especially for the decay functions:

"Decay functions score a document with a function that decays depending  
on the distance of a numeric field value of the document from a user  
given origin. This is similar to a range query, but with smooth edges  
instead of boxes."

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Have a look at all the beautiful example plots Britta created.. 🙂

Best regards,  
Hannes

On 15.04.2014 15:18, Guy Bowden wrote:

> Hi,
> 
> I have documents (accommodations) stored with a numeric attribute - "number  
> of beds"
> 
> I'd like to be able to boost by a certain amount if that number is close to  
> a search query.
> 
> e.g. prefer documents with a number of beds close to what is being searched  
> for.
> 
> This will be added to the rest of the search criteria - is there a way to  
> do this? I can filter by a number within a range, but would like the  
> results returned to take some ordering from the closeness of the number  
> searched for.
> 
> Thanks  
> Guy

--  
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/534D37E5.8060609%40hkorte.com](https://groups.google.com/d/msgid/elasticsearch/534D37E5.8060609%40hkorte.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:35am UTC](https://discuss.elastic.co/t/boosting-for-a-number-near-x/17026/3 "2017-07-06T01:35:45Z")

</div>


