# Java API - boost field on query

**URL:** <https://discuss.elastic.co/t/java-api-boost-field-on-query/4156>\
**Category:** Elasticsearch\
**Created:** [March 24, 2011, 8:53pm UTC](https://discuss.elastic.co/t/java-api-boost-field-on-query/4156 "2011-03-24T20:53:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbro](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mbro](https://discuss.elastic.co/u/mbro)\
**Post date:** [March 24, 2011, 8:53pm UTC](https://discuss.elastic.co/t/java-api-boost-field-on-query/4156/1 "2011-03-24T20:53:56Z")

</div>

It's not clear to me how I can boost a specific field on the query  
using the Java API. Basically, I'd like to do a query string search  
across all fields and boost one of the fields so that if the search  
string is found in that field, those documents will be ranked higher.

Is this possible using the Java API?

Thanks.

Mike

---

<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:** [March 24, 2011, 9:04pm UTC](https://discuss.elastic.co/t/java-api-boost-field-on-query/4156/2 "2011-03-24T21:04:14Z")

</div>

Few things:

1. You can define boost at index time for field, when you search on the \_all field, if there is a match for that field content, it will be boosted.

2. You can use the query\_string and provide the list of fields you wish to search on, each with different boost levels (QueryStringBuilder#field(String field, float boost).

A note, that I keep repeating and its in the docs, not sure why people keep missing it. The REST API is built on top of the Java API. There is no way to have something exposed in REST that is not exposed (in some way) using the Java API.  
On Thursday, March 24, 2011 at 10:53 PM, Mike Brocious wrote:

> It's not clear to me how I can boost a specific field on the query  
> using the Java API. Basically, I'd like to do a query string search  
> across all fields and boost one of the fields so that if the search  
> string is found in that field, those documents will be ranked higher.
> 
> Is this possible using the Java API?
> 
> Thanks.
> 
> Mike

---

<div class="post-metadata">

**Author:** ![mbro](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mbro](https://discuss.elastic.co/u/mbro)\
**Post date:** [March 25, 2011, 12:38am UTC](https://discuss.elastic.co/t/java-api-boost-field-on-query/4156/3 "2011-03-25T00:38:40Z")

</div>

Thanks, Shay. Appreciate your patience with us as we come up to speed  
on ES.

I found the boost reference in the REST API...it simply wasn't clear  
to me how to do the same thing in the Java API. I looked at the  
QueryStringBuilder, but just missed the field(String, float) method.

Mike

On Mar 24, 5:04 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Few things:
> 
> 1. You can define boost at index time for field, when you search on the \_all field, if there is a match for that field content, it will be boosted.
> 
> 2. You can use the query\_string and provide the list of fields you wish to search on, each with different boost levels (QueryStringBuilder#field(String field, float boost).
> 
> A note, that I keep repeating and its in the docs, not sure why people keep missing it. The REST API is built on top of the Java API. There is no way to have something exposed in REST that is not exposed (in some way) using the Java API.
> 
> On Thursday, March 24, 2011 at 10:53 PM, Mike Brocious wrote:
> 
> > It's not clear to me how I can boost a specific field on the query  
> > using the Java API. Basically, I'd like to do a query string search  
> > across all fields and boost one of the fields so that if the search  
> > string is found in that field, those documents will be ranked higher.
> 
> > Is this possible using the Java API?
> 
> > Thanks.
> 
> > Mike

---

<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:** [March 25, 2011, 7:02pm UTC](https://discuss.elastic.co/t/java-api-boost-field-on-query/4156/4 "2011-03-25T19:02:36Z")

</div>

No problem, thats what the mailing list is for 🙂  
On Friday, March 25, 2011 at 2:38 AM, Mike Brocious wrote:

> Thanks, Shay. Appreciate your patience with us as we come up to speed  
> on ES.
> 
> I found the boost reference in the REST API...it simply wasn't clear  
> to me how to do the same thing in the Java API. I looked at the  
> QueryStringBuilder, but just missed the field(String, float) method.
> 
> Mike
> 
> On Mar 24, 5:04 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Few things:
> > 
> > 1. You can define boost at index time for field, when you search on the \_all field, if there is a match for that field content, it will be boosted.
> > 
> > 2. You can use the query\_string and provide the list of fields you wish to search on, each with different boost levels (QueryStringBuilder#field(String field, float boost).
> > 
> > A note, that I keep repeating and its in the docs, not sure why people keep missing it. The REST API is built on top of the Java API. There is no way to have something exposed in REST that is not exposed (in some way) using the Java API.
> > 
> > On Thursday, March 24, 2011 at 10:53 PM, Mike Brocious wrote:
> > 
> > > It's not clear to me how I can boost a specific field on the query  
> > > using the Java API. Basically, I'd like to do a query string search  
> > > across all fields and boost one of the fields so that if the search  
> > > string is found in that field, those documents will be ranked higher.
> > 
> > > Is this possible using the Java API?
> > 
> > > Thanks.
> > 
> > > Mike

---

<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:09am UTC](https://discuss.elastic.co/t/java-api-boost-field-on-query/4156/5 "2017-07-06T04:09:18Z")

</div>


