# CustomScoreQueryBuilder api working strangely

**URL:** <https://discuss.elastic.co/t/customscorequerybuilder-api-working-strangely/4916>\
**Category:** Elasticsearch\
**Created:** [July 21, 2011, 5:27am UTC](https://discuss.elastic.co/t/customscorequerybuilder-api-working-strangely/4916 "2011-07-21T05:27:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nachiket](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nachiket](https://discuss.elastic.co/u/nachiket)\
**Post date:** [July 21, 2011, 5:27am UTC](https://discuss.elastic.co/t/customscorequerybuilder-api-working-strangely/4916/1 "2011-07-21T05:27:00Z")

</div>

Hi.  
I am using Custom Score query in my project.  
It needs mainly 2 things: Query and Script.  
For normal queries it works fine.  
But if I put a nested query like bool query, then it puts script in  
wrong position.  
Is there a mistake in the api or am I not writing it correctly?

My code is at git://gist.github.com/1096535.git.  
(The script is not at the query position.)

Can anybody please help me on this?

Regards.

---

<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:** [July 21, 2011, 6:18am UTC](https://discuss.elastic.co/t/customscorequerybuilder-api-working-strangely/4916/2 "2011-07-21T06:18:51Z")

</div>

Heya,

Its a bug in how the boosting query builder generates the query, fixed in  
0.17 branch and master:  
[Java API: BoostingQueryBuilder does not build the query correctly · Issue #1141 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1141).

-shay.banon

On Thu, Jul 21, 2011 at 8:27 AM, nachiket bhagwat \<[nachiketbhagwat@gmail.com](mailto:nachiketbhagwat@gmail.com)

> wrote:

> Hi.  
> I am using Custom Score query in my project.  
> It needs mainly 2 things: Query and Script.  
> For normal queries it works fine.  
> But if I put a nested query like bool query, then it puts script in  
> wrong position.  
> Is there a mistake in the api or am I not writing it correctly?
> 
> My code is at git://gist.github.com/1096535.git.  
> (The script is not at the query position.)
> 
> Can anybody please help me on this?
> 
> Regards.

---

<div class="post-metadata">

**Author:** ![nachiket](https://avatars.discourse-cdn.com/v4/letter/n/4491bb/32.png) [@nachiket](https://discuss.elastic.co/u/nachiket)\
**Post date:** [July 23, 2011, 1:33pm UTC](https://discuss.elastic.co/t/customscorequerybuilder-api-working-strangely/4916/3 "2011-07-23T13:33:24Z")

</div>

Hi.  
I upgraded to 0.17.1 and then too the problem persisted.  
My code is at [Query Builders unable to build queries. · GitHub](https://gist.github.com/1101431).  
Can someone take a look at it?

Regards.

On Jul 21, 11:18 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> Heya,
> 
> Its a bug in how the boosting query builder generates the query, fixed in  
> 0.17 branch and master:[Java API: BoostingQueryBuilder does not build the query correctly · Issue #1141 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1141).
> 
> -shay.banon
> 
> On Thu, Jul 21, 2011 at 8:27 AM, nachiket bhagwat \<[nachiketbhag...@gmail.com](mailto:nachiketbhag...@gmail.com)
> 
> > wrote:  
> > Hi.  
> > I am using Custom Score query in my project.  
> > It needs mainly 2 things: Query and Script.  
> > For normal queries it works fine.  
> > But if I put a nested query like bool query, then it puts script in  
> > wrong position.  
> > Is there a mistake in the api or am I not writing it correctly?
> 
> > My code is at git://gist.github.com/1096535.git.  
> > (The script is not at the query position.)
> 
> > Can anybody please help me on this?
> 
> > Regards.

---

<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:** [July 23, 2011, 2:59pm UTC](https://discuss.elastic.co/t/customscorequerybuilder-api-working-strangely/4916/4 "2011-07-23T14:59:24Z")

</div>

It will be fixed in 0.17.2 (check the tags at:  
[Java API: BoostingQueryBuilder does not build the query correctly · Issue #1141 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1141))

On Sat, Jul 23, 2011 at 4:33 PM, nachiket bhagwat \<[nachiketbhagwat@gmail.com](mailto:nachiketbhagwat@gmail.com)

> wrote:

> Hi.  
> I upgraded to 0.17.1 and then too the problem persisted.  
> My code is at [Query Builders unable to build queries. · GitHub](https://gist.github.com/1101431).  
> Can someone take a look at it?
> 
> Regards.
> 
> On Jul 21, 11:18 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > Heya,
> > 
> > Its a bug in how the boosting query builder generates the query, fixed  
> > in  
> > 0.17 branch and master:  
> > [Java API: BoostingQueryBuilder does not build the query correctly · Issue #1141 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1141).
> > 
> > -shay.banon
> > 
> > On Thu, Jul 21, 2011 at 8:27 AM, nachiket bhagwat \<  
> > [nachiketbhag...@gmail.com](mailto:nachiketbhag...@gmail.com)
> > 
> > > wrote:  
> > > Hi.  
> > > I am using Custom Score query in my project.  
> > > It needs mainly 2 things: Query and Script.  
> > > For normal queries it works fine.  
> > > But if I put a nested query like bool query, then it puts script in  
> > > wrong position.  
> > > Is there a mistake in the api or am I not writing it correctly?
> > 
> > > My code is at git://gist.github.com/1096535.git.  
> > > (The script is not at the query position.)
> > 
> > > Can anybody please help me on this?
> > 
> > > Regards.

---

<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:59am UTC](https://discuss.elastic.co/t/customscorequerybuilder-api-working-strangely/4916/5 "2017-07-06T03:59:43Z")

</div>


