# Boosting results based on another field?

**URL:** <https://discuss.elastic.co/t/boosting-results-based-on-another-field/4536>\
**Category:** Elasticsearch\
**Created:** [June 2, 2011, 6:48pm UTC](https://discuss.elastic.co/t/boosting-results-based-on-another-field/4536 "2011-06-02T18:48:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy\_2](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Andy\_2](https://discuss.elastic.co/u/Andy_2)\
**Post date:** [June 2, 2011, 6:48pm UTC](https://discuss.elastic.co/t/boosting-results-based-on-another-field/4536/1 "2011-06-02T18:48:08Z")

</div>

Hi,

I'm new to ElasticSearch, trying to see if I could migrate a website  
from Solr to ES.

One of the features I need is to boost search results based on the  
value of another field. All my documents have a field "popularity"  
which is an integer. When a user makes a search, I want to return  
results that are the best match but also take popularity into  
account.

Right now in Solr when someone searches for "foo" I do something  
like:

q={!boost b=log(popularity)}foo

which basically multiplies the "natural" scoring of a document with  
the log of the popularity of that document.

Is it possible to do something similar in ElasticSearch?

Thanks.

---

<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:** [June 2, 2011, 6:55pm UTC](https://discuss.elastic.co/t/boosting-results-based-on-another-field/4536/2 "2011-06-02T18:55:43Z")

</div>

Hi Andy

> Right now in Solr when someone searches for "foo" I do something  
> like:
> 
> q={!boost b=log(popularity)}foo
> 
> which basically multiplies the "natural" scoring of a document with  
> the log of the popularity of that document.

You can use a custom\_score query to do this:

> **[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.

clint

---

<div class="post-metadata">

**Author:** ![Andy\_2](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Andy\_2](https://discuss.elastic.co/u/Andy_2)\
**Post date:** [June 2, 2011, 7:58pm UTC](https://discuss.elastic.co/t/boosting-results-based-on-another-field/4536/3 "2011-06-02T19:58:44Z")

</div>

Great! Thanks Clinton.

On Jun 2, 2:55 pm, Clinton Gormley [clin...@iannounce.co.uk](mailto:clin...@iannounce.co.uk) wrote:

> Hi Andy
> 
> > Right now in Solr when someone searches for "foo" I do something  
> > like:
> 
> > q={!boost b=log(popularity)}foo
> 
> > which basically multiplies the "natural" scoring of a document with  
> > the log of the popularity of that document.
> 
> You can use a custom\_score query to do this:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/custom-score-q)...
> 
> clint

---

<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, 4:04am UTC](https://discuss.elastic.co/t/boosting-results-based-on-another-field/4536/4 "2017-07-06T04:04:49Z")

</div>


