# Boosting queries by type

**URL:** <https://discuss.elastic.co/t/boosting-queries-by-type/5632>\
**Category:** Elasticsearch\
**Created:** [October 18, 2011, 6:23pm UTC](https://discuss.elastic.co/t/boosting-queries-by-type/5632 "2011-10-18T18:23:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![James\_Wilson](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@James\_Wilson](https://discuss.elastic.co/u/James_Wilson)\
**Post date:** [October 18, 2011, 6:23pm UTC](https://discuss.elastic.co/t/boosting-queries-by-type/5632/1 "2011-10-18T18:23:59Z")

</div>

Suppose I am searching using a text query (or query\_string, field,  
etc.) and would like to boost any results where a document field has a  
specific value (in particular, \_type). How can I express this in the  
query DSL?

---

<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:** [October 18, 2011, 9:27pm UTC](https://discuss.elastic.co/t/boosting-queries-by-type/5632/2 "2011-10-18T21:27:16Z")

</div>

I gisted two options that you can use, one using bool query (with should  
clauses), and one using custom\_filters\_score (preferable):

> <https://gist.github.com/kimchy/1296774>

On Tue, Oct 18, 2011 at 8:23 PM, James Wilson [jwilson556@gmail.com](mailto:jwilson556@gmail.com) wrote:

> Suppose I am searching using a text query (or query\_string, field,  
> etc.) and would like to boost any results where a document field has a  
> specific value (in particular, \_type). How can I express this in the  
> query DSL?

---

<div class="post-metadata">

**Author:** ![James\_Wilson](https://avatars.discourse-cdn.com/v4/letter/j/53a042/32.png) [@James\_Wilson](https://discuss.elastic.co/u/James_Wilson)\
**Post date:** [October 18, 2011, 11:14pm UTC](https://discuss.elastic.co/t/boosting-queries-by-type/5632/3 "2011-10-18T23:14:02Z")

</div>

Awesome, thank you.

On Oct 18, 2:27 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> I gisted two options that you can use, one using bool query (with should  
> clauses), and one using custom\_filters\_score (preferable):[gist:1296774 · GitHub](https://gist.github.com/1296774)
> 
> On Tue, Oct 18, 2011 at 8:23 PM, James Wilson [jwilson...@gmail.com](mailto:jwilson...@gmail.com) wrote:
> 
> > Suppose I am searching using a text query (or query\_string, field,  
> > etc.) and would like to boost any results where a document field has a  
> > specific value (in particular, \_type). How can I express this in the  
> > query DSL?

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [October 19, 2011, 8:24pm UTC](https://discuss.elastic.co/t/boosting-queries-by-type/5632/4 "2011-10-19T20:24:04Z")

</div>

preferable in terms of performance?

On 18 Okt., 23:27, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> I gisted two options that you can use, one using bool query (with should  
> clauses), and one using custom\_filters\_score (preferable):[gist:1296774 · GitHub](https://gist.github.com/1296774)
> 
> On Tue, Oct 18, 2011 at 8:23 PM, James Wilson [jwilson...@gmail.com](mailto:jwilson...@gmail.com) wrote:
> 
> > Suppose I am searching using a text query (or query\_string, field,  
> > etc.) and would like to boost any results where a document field has a  
> > specific value (in particular, \_type). How can I express this in the  
> > query DSL?

---

<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:** [October 19, 2011, 8:40pm UTC](https://discuss.elastic.co/t/boosting-queries-by-type/5632/5 "2011-10-19T20:40:47Z")

</div>

Yes.

On Wed, Oct 19, 2011 at 10:24 PM, Karussell [tableyourtime@googlemail.com](mailto:tableyourtime@googlemail.com)wrote:

> preferable in terms of performance?
> 
> On 18 Okt., 23:27, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > I gisted two options that you can use, one using bool query (with should  
> > clauses), and one using custom\_filters\_score (preferable):  
> > [gist:1296774 · GitHub](https://gist.github.com/1296774)
> > 
> > On Tue, Oct 18, 2011 at 8:23 PM, James Wilson [jwilson...@gmail.com](mailto:jwilson...@gmail.com)  
> > wrote:
> > 
> > > Suppose I am searching using a text query (or query\_string, field,  
> > > etc.) and would like to boost any results where a document field has a  
> > > specific value (in particular, \_type). How can I express this in the  
> > > query DSL?

---

<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:51am UTC](https://discuss.elastic.co/t/boosting-queries-by-type/5632/6 "2017-07-06T03:51:22Z")

</div>


