# Field boosting at query time

**URL:** <https://discuss.elastic.co/t/field-boosting-at-query-time/19162>\
**Category:** Elasticsearch\
**Created:** [August 8, 2014, 1:15pm UTC](https://discuss.elastic.co/t/field-boosting-at-query-time/19162 "2014-08-08T13:15:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Topper1](https://avatars.discourse-cdn.com/v4/letter/m/7bcc69/32.png) [@Mike\_Topper1](https://discuss.elastic.co/u/Mike_Topper1)\
**Post date:** [August 8, 2014, 1:15pm UTC](https://discuss.elastic.co/t/field-boosting-at-query-time/19162/1 "2014-08-08T13:15:01Z")

</div>

Hello,

sorry if this question is already explained in the docs but i tried to go  
through all the boosting and custom scoring documentation and didn't find  
what i was looking for.

I'm trying to write a query that will give preference to certain fields  
when doing a match query on "\_all". so for example to be able to score  
higher when the query matches the title and author fields than it would  
when it matches on a subject field. I've seen various ways to boost scores  
based on field values as well as how to add a boost to the field mappings  
on index time, but what if I want to do the field boost on query time  
instead?

here's a query i'm running. what would be the best way for example to add  
a 2.0 boost to the title field?

[http://pastebin.com/XBwat3zy](http://pastebin.com/XBwat3zy)

-Mike

--  
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/CALdNedLu0q3c-vyeqbyDN\_vaR%3DoBTA45Bk5vd6Fj2X8f0BbcAA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CALdNedLu0q3c-vyeqbyDN_vaR%3DoBTA45Bk5vd6Fj2X8f0BbcAA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Tihomir\_Lichev1](https://avatars.discourse-cdn.com/v4/letter/t/f08c70/32.png) [@Tihomir\_Lichev1](https://discuss.elastic.co/u/Tihomir_Lichev1)\
**Post date:** [August 11, 2014, 11:49am UTC](https://discuss.elastic.co/t/field-boosting-at-query-time/19162/2 "2014-08-11T11:49:57Z")

</div>

Hi,  
If I'm not wrong you cannot boost fields in \_all field on query time.  
Querying the \_all field should take in account the index-time boost, but  
for query-time boost you will need the field names you are searching in.  
You can set boost for a field at query time using "^":  
"title^5.0"

You can probably do query on ["title^5.0", "\_all"] and don't set the boost  
in the mapping (index time)  
This way the matches in \_all will have base boost of 1.0, but if there is  
match on "title" field you should get additional boost of 5.0

Regs  
Tihomir

08 август 2014, петък, 16:15:55 UTC+3, Mike Topper написа:

> Hello,
> 
> sorry if this question is already explained in the docs but i tried to go  
> through all the boosting and custom scoring documentation and didn't find  
> what i was looking for.
> 
> I'm trying to write a query that will give preference to certain fields  
> when doing a match query on "\_all". so for example to be able to score  
> higher when the query matches the title and author fields than it would  
> when it matches on a subject field. I've seen various ways to boost scores  
> based on field values as well as how to add a boost to the field mappings  
> on index time, but what if I want to do the field boost on query time  
> instead?
> 
> here's a query i'm running. what would be the best way for example to add  
> a 2.0 boost to the title field?
> 
> [GET /catalog\_data/book/\_search?routing=1{ "fields": [], "query": { - Pastebin.com](http://pastebin.com/XBwat3zy)
> 
> -Mike

--  
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/2cd02a13-f4af-48b2-bd69-cf4d233c18ab%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2cd02a13-f4af-48b2-bd69-cf4d233c18ab%40googlegroups.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:09am UTC](https://discuss.elastic.co/t/field-boosting-at-query-time/19162/3 "2017-07-06T01:09:35Z")

</div>


