# Easiest way to boost field value?

**URL:** <https://discuss.elastic.co/t/easiest-way-to-boost-field-value/6816>\
**Category:** Elasticsearch\
**Created:** [February 27, 2012, 9:54am UTC](https://discuss.elastic.co/t/easiest-way-to-boost-field-value/6816 "2012-02-27T09:54:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tomasz\_Kloc](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tomasz\_Kloc](https://discuss.elastic.co/u/Tomasz_Kloc)\
**Post date:** [February 27, 2012, 9:54am UTC](https://discuss.elastic.co/t/easiest-way-to-boost-field-value/6816/1 "2012-02-27T09:54:03Z")

</div>

hello,

what is the easiest way to boost field in TextQuery? lets say i have two  
documents:

{'title': 'string1', description: ''}  
{'title': 'string2', description: 'string1' }

and i want to find documents where title OR description contains  
'string1', but matches in 'title' attribute should have higher score  
than 'description'?

tk

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 27, 2012, 1:12pm UTC](https://discuss.elastic.co/t/easiest-way-to-boost-field-value/6816/2 "2012-02-27T13:12:29Z")

</div>

You can associate a boost value with a query:

{  
"text" : {  
"desc" : {  
"query" : "text here",  
"boost" : 5.0f  
}  
}  
}

Another option is to wrap the query in a custom\_boost\_query ([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/custom-boost-factor-query.html)) which simply multiplies the wrapped query by the custom boost factor.

On Monday, February 27, 2012 at 11:54 AM, Tomasz Kloc wrote:

> hello,
> 
> what is the easiest way to boost field in TextQuery? lets say i have two  
> documents:
> 
> {'title': 'string1', description: ''}  
> {'title': 'string2', description: 'string1' }
> 
> and i want to find documents where title OR description contains  
> 'string1', but matches in 'title' attribute should have higher score  
> than 'description'?
> 
> tk

---

<div class="post-metadata">

**Author:** ![Tomasz\_Kloc](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tomasz\_Kloc](https://discuss.elastic.co/u/Tomasz_Kloc)\
**Post date:** [March 15, 2012, 9:50am UTC](https://discuss.elastic.co/t/easiest-way-to-boost-field-value/6816/3 "2012-03-15T09:50:33Z")

</div>

Thanks Shay, I ended up with query like this:

{'query':  
{ 'bool':  
{ 'should':  
[  
{'text': {'title': {'query': 'my querystring', 'operator': 'and',  
'boost': 5 } } },  
{'text': {'description': { 'query': 'my querystring', 'operator':  
'and', 'boost': 1 } } }  
]  
}  
}  
}

On 27.02.2012 14:12, Shay Banon wrote:

> You can associate a boost value with a query:
> 
> {  
> "text" : {  
> "desc" : {  
> "query" : "text here",  
> "boost" : 5.0f  
> }  
> }  
> }
> 
> Another option is to wrap the query in a custom\_boost\_query  
> ([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/custom-boost-factor-query.html))  
> which simply multiplies the wrapped query by the custom boost factor.
> 
> On Monday, February 27, 2012 at 11:54 AM, Tomasz Kloc wrote:
> 
> > hello,
> > 
> > what is the easiest way to boost field in TextQuery? lets say i have two  
> > documents:
> > 
> > {'title': 'string1', description: ''}  
> > {'title': 'string2', description: 'string1' }
> > 
> > and i want to find documents where title OR description contains  
> > 'string1', but matches in 'title' attribute should have higher score  
> > than 'description'?
> > 
> > tk

---

<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:36am UTC](https://discuss.elastic.co/t/easiest-way-to-boost-field-value/6816/4 "2017-07-06T03:36:02Z")

</div>


