# Boosting query howto?

**URL:** <https://discuss.elastic.co/t/boosting-query-howto/19028>\
**Category:** Elasticsearch\
**Created:** [August 1, 2014, 12:39pm UTC](https://discuss.elastic.co/t/boosting-query-howto/19028 "2014-08-01T12:39:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bernd\_Fehling\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Bernd\_Fehling\_2](https://discuss.elastic.co/u/Bernd_Fehling_2)\
**Post date:** [August 1, 2014, 12:39pm UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/1 "2014-08-01T12:39:27Z")

</div>

I tried the following query

{  
"fields": [  
"score",  
"title",  
"price"  
],  
"boosting": {  
"positive": {  
"term": {  
"text": "einzelhandel"  
}  
},  
"negative": {  
"term": {  
"price": "100"  
}  
},  
"negative\_boost": 0.0025,  
"boost": 200  
}  
}

What I'm trying to do is to search for "einzelhandel" with a boost of 200  
(e.g. "text:einzelhandel^200")  
and have hits which also match a price of 100 get boosted with 400 (e.g.  
"price:100^400") to have them before all other prices.  
But this doen't work, any better ideas?

Also, the fields in the result are not limited to "score,title,price".  
Is this not possible with boosting query?

Regards,  
Bernd

--  
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/b81716ca-6c07-493e-9645-36bc21fce798%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b81716ca-6c07-493e-9645-36bc21fce798%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 1, 2014, 2:07pm UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/2 "2014-08-01T14:07:00Z")

</div>

Have you tried boosting boolean query clauses?

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

Jörg

On Fri, Aug 1, 2014 at 2:39 PM, Bernd Fehling [bernd.fehling@gmail.com](mailto:bernd.fehling@gmail.com)  
wrote:

> I tried the following query
> 
> {  
> "fields": [  
> "score",  
> "title",  
> "price"  
> ],  
> "boosting": {  
> "positive": {  
> "term": {  
> "text": "einzelhandel"  
> }  
> },  
> "negative": {  
> "term": {  
> "price": "100"  
> }  
> },  
> "negative\_boost": 0.0025,  
> "boost": 200  
> }  
> }
> 
> What I'm trying to do is to search for "einzelhandel" with a boost of 200  
> (e.g. "text:einzelhandel^200")  
> and have hits which also match a price of 100 get boosted with 400 (e.g.  
> "price:100^400") to have them before all other prices.  
> But this doen't work, any better ideas?
> 
> Also, the fields in the result are not limited to "score,title,price".  
> Is this not possible with boosting query?
> 
> Regards,  
> Bernd
> 
> --  
> 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/b81716ca-6c07-493e-9645-36bc21fce798%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b81716ca-6c07-493e-9645-36bc21fce798%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/b81716ca-6c07-493e-9645-36bc21fce798%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b81716ca-6c07-493e-9645-36bc21fce798%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAKdsXoHmbtRa\_JgD0DuyS-KnjP0RFwgyCE%2BpSUZqLd8Vyx54%2Bw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoHmbtRa_JgD0DuyS-KnjP0RFwgyCE%2BpSUZqLd8Vyx54%2Bw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bernd\_Fehling\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Bernd\_Fehling\_2](https://discuss.elastic.co/u/Bernd_Fehling_2)\
**Post date:** [August 4, 2014, 6:13am UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/3 "2014-08-04T06:13:10Z")

</div>

Hi Jörg,  
thanks for the advise, it seams to be my solution.

Are there any API javadocs for ES?  
It takes me 3 to 4 times longer writing something for ES than for Solr  
because of searching through the sources  
and no useful javadocs.

Bernd

Am Freitag, 1. August 2014 16:07:10 UTC+2 schrieb Jörg Prante:

> Have you tried boosting boolean query clauses?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_boosting_query_clauses.html)
> 
> Jörg

--  
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/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bernd\_Fehling\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Bernd\_Fehling\_2](https://discuss.elastic.co/u/Bernd_Fehling_2)\
**Post date:** [August 4, 2014, 9:31am UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/4 "2014-08-04T09:31:14Z")

</div>

Now this is strange, I have same mapping/settings for both ES and Solr, but  
ES ist boosting wrong!!!  
If I add a boost to Solr all boosted hits are listed first.  
If I add the same boost to ES only some of the boosted hits are listed  
first.

Bernd

Am Montag, 4. August 2014 08:13:10 UTC+2 schrieb Bernd Fehling:

> Hi Jörg,  
> thanks for the advise, it seams to be my solution.
> 
> Are there any API javadocs for ES?  
> It takes me 3 to 4 times longer writing something for ES than for Solr  
> because of searching through the sources  
> and no useful javadocs.
> 
> Bernd
> 
> Am Freitag, 1. August 2014 16:07:10 UTC+2 schrieb Jörg Prante:
> 
> > Have you tried boosting boolean query clauses?
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/current/_boosting_query_clauses.html)
> > 
> > Jörg

--  
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/056aaaa1-6b17-4ee7-a8b2-be47d22ca166%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/056aaaa1-6b17-4ee7-a8b2-be47d22ca166%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [August 4, 2014, 12:00pm UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/5 "2014-08-04T12:00:52Z")

</div>

Yes, missing Javadoc online is a pity. So I have prepared a javadoc for  
Elasticsearch 1.3.1 here

[http://xbib.org/elasticsearch/1.3.1/apidocs/](http://xbib.org/elasticsearch/1.3.1/apidocs/)

Jörg

On Mon, Aug 4, 2014 at 8:13 AM, Bernd Fehling [bernd.fehling@gmail.com](mailto:bernd.fehling@gmail.com)  
wrote:

> Hi Jörg,  
> thanks for the advise, it seams to be my solution.
> 
> Are there any API javadocs for ES?  
> It takes me 3 to 4 times longer writing something for ES than for Solr  
> because of searching through the sources  
> and no useful javadocs.
> 
> Bernd
> 
> Am Freitag, 1. August 2014 16:07:10 UTC+2 schrieb Jörg Prante:
> 
> > Have you tried boosting boolean query clauses?
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/guide/)  
> > current/\_boosting\_query\_clauses.html
> > 
> > Jörg
> > 
> > --  
> > 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/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CAKdsXoEi\_RVS2PUSgMyyieTYSfrDGMj8UBjCOx7xLV5xOb3AWw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEi_RVS2PUSgMyyieTYSfrDGMj8UBjCOx7xLV5xOb3AWw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Bernd\_Fehling\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Bernd\_Fehling\_2](https://discuss.elastic.co/u/Bernd_Fehling_2)\
**Post date:** [August 4, 2014, 12:28pm UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/6 "2014-08-04T12:28:44Z")

</div>

Thanks a lot.  
+1

This MUST be on the ES Web page.

Am Montag, 4. August 2014 14:00:59 UTC+2 schrieb Jörg Prante:

> Yes, missing Javadoc online is a pity. So I have prepared a javadoc for  
> Elasticsearch 1.3.1 here
> 
> [http://xbib.org/elasticsearch/1.3.1/apidocs/](http://xbib.org/elasticsearch/1.3.1/apidocs/)
> 
> Jörg
> 
> On Mon, Aug 4, 2014 at 8:13 AM, Bernd Fehling \<[bernd....@gmail.com](mailto:bernd....@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > Hi Jörg,  
> > thanks for the advise, it seams to be my solution.
> > 
> > Are there any API javadocs for ES?  
> > It takes me 3 to 4 times longer writing something for ES than for Solr  
> > because of searching through the sources  
> > and no useful javadocs.
> > 
> > Bernd
> > 
> > Am Freitag, 1. August 2014 16:07:10 UTC+2 schrieb Jörg Prante:
> > 
> > > Have you tried boosting boolean query clauses?
> > > 
> > > [http://www.elasticsearch.org/guide/en/elasticsearch/guide/](http://www.elasticsearch.org/guide/en/elasticsearch/guide/)  
> > > current/\_boosting\_query\_clauses.html
> > > 
> > > Jörg
> > > 
> > > --  
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > > To view this discussion on the web visit  
> > > [https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com)  
> > > [https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > .
> > 
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/b0fd691a-03ac-4119-b3c6-9bb963320305%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b0fd691a-03ac-4119-b3c6-9bb963320305%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Ivan](https://avatars.discourse-cdn.com/v4/letter/i/df788c/32.png) [@Ivan](https://discuss.elastic.co/u/Ivan)\
**Post date:** [August 4, 2014, 5:53pm UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/7 "2014-08-04T17:53:28Z")

</div>

Javadocs also available at

[http://jenkins.elasticsearch.org/job/Elasticsearch%20Master%20Branch%20Javadoc/Elasticsearch\_API\_Documentation/](http://jenkins.elasticsearch.org/job/Elasticsearch%20Master%20Branch%20Javadoc/Elasticsearch_API_Documentation/)

[http://javadoc.kyubu.de/elasticsearch/](http://javadoc.kyubu.de/elasticsearch/) (unofficial)

--  
Ivan

On Mon, Aug 4, 2014 at 5:28 AM, Bernd Fehling [bernd.fehling@gmail.com](mailto:bernd.fehling@gmail.com)  
wrote:

> Thanks a lot.  
> +1
> 
> This MUST be on the ES Web page.
> 
> Am Montag, 4. August 2014 14:00:59 UTC+2 schrieb Jörg Prante:
> 
> > Yes, missing Javadoc online is a pity. So I have prepared a javadoc for  
> > Elasticsearch 1.3.1 here
> > 
> > [http://xbib.org/elasticsearch/1.3.1/apidocs/](http://xbib.org/elasticsearch/1.3.1/apidocs/)
> > 
> > Jörg
> > 
> > On Mon, Aug 4, 2014 at 8:13 AM, Bernd Fehling [bernd....@gmail.com](mailto:bernd....@gmail.com)  
> > wrote:
> > 
> > > Hi Jörg,  
> > > thanks for the advise, it seams to be my solution.
> > > 
> > > Are there any API javadocs for ES?  
> > > It takes me 3 to 4 times longer writing something for ES than for Solr  
> > > because of searching through the sources  
> > > and no useful javadocs.
> > > 
> > > Bernd
> > > 
> > > Am Freitag, 1. August 2014 16:07:10 UTC+2 schrieb Jörg Prante:
> > > 
> > > > Have you tried boosting boolean query clauses?
> > > > 
> > > > [http://www.elasticsearch.org/guide/en/elasticsearch/guide/cu](http://www.elasticsearch.org/guide/en/elasticsearch/guide/cu)  
> > > > rrent/\_boosting\_query\_clauses.html
> > > > 
> > > > Jörg
> > > > 
> > > > --  
> > > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > > To view this discussion on the web visit [https://groups.google.com/d/](https://groups.google.com/d/)  
> > > > msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%  
> > > > [40googlegroups.com](http://40googlegroups.com)  
> > > > [https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/489eceec-df34-4cda-86ef-bb354a162848%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > > > .
> > > 
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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/b0fd691a-03ac-4119-b3c6-9bb963320305%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b0fd691a-03ac-4119-b3c6-9bb963320305%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/b0fd691a-03ac-4119-b3c6-9bb963320305%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/b0fd691a-03ac-4119-b3c6-9bb963320305%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .
> 
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/CALY%3DcQDLrzRUeHfYOorJ7vPxWmwpiNUHocKBSHC1a7tbePM1vg%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALY%3DcQDLrzRUeHfYOorJ7vPxWmwpiNUHocKBSHC1a7tbePM1vg%40mail.gmail.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:10am UTC](https://discuss.elastic.co/t/boosting-query-howto/19028/8 "2017-07-06T01:10:53Z")

</div>


