# Custom Scoring on nested objects

**URL:** <https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431>\
**Category:** Elasticsearch\
**Created:** [January 18, 2012, 6:16pm UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431 "2012-01-18T18:16:20Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arny](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Arny](https://discuss.elastic.co/u/Arny)\
**Post date:** [January 18, 2012, 6:16pm UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/1 "2012-01-18T18:16:20Z")

</div>

Hi,  
is it possible to add scoring on nested filters?  
I can't get it to work.

Right now I'm using CustomFiltersScoreQueryBuilder and adding  
nestedFilters to it via NestedFilterBuilder.

Any help appreciated.  
Thanks

Arny

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [January 18, 2012, 8:45pm UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/2 "2012-01-18T20:45:46Z")

</div>

Hi Amy

On Wed, Jan 18, 2012 at 7:16 PM, Arny [arny.ok@googlemail.com](mailto:arny.ok@googlemail.com) wrote:

> Hi,  
> is it possible to add scoring on nested filters?  
> I can't get it to work.

Could you open an issue?

thanks

Clint

> Right now I'm using CustomFiltersScoreQueryBuilder and adding  
> nestedFilters to it via NestedFilterBuilder.
> 
> Any help appreciated.  
> Thanks
> 
> Arny

---

<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:** [January 18, 2012, 9:30pm UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/3 "2012-01-18T21:30:21Z")

</div>

What is the problem? Can you gist a curl example?

On Wed, Jan 18, 2012 at 8:16 PM, Arny [arny.ok@googlemail.com](mailto:arny.ok@googlemail.com) wrote:

> Hi,  
> is it possible to add scoring on nested filters?  
> I can't get it to work.
> 
> Right now I'm using CustomFiltersScoreQueryBuilder and adding  
> nestedFilters to it via NestedFilterBuilder.
> 
> Any help appreciated.  
> Thanks
> 
> Arny

---

<div class="post-metadata">

**Author:** ![Arny](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Arny](https://discuss.elastic.co/u/Arny)\
**Post date:** [January 18, 2012, 9:58pm UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/4 "2012-01-18T21:58:14Z")

</div>

I'm using the Java library.  
Isn't there an example on how to use CustomFiltersScoreQueryBuilder  
with script on nested objects?

On Jan 18, 10:30 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> What is the problem? Can you gist a curl example?
> 
> On Wed, Jan 18, 2012 at 8:16 PM, Arny [arny...@googlemail.com](mailto:arny...@googlemail.com) wrote:
> 
> > Hi,  
> > is it possible to add scoring on nested filters?  
> > I can't get it to work.
> 
> > Right now I'm using CustomFiltersScoreQueryBuilder and adding  
> > nestedFilters to it via NestedFilterBuilder.
> 
> > Any help appreciated.  
> > Thanks
> 
> > Arny

---

<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:** [January 18, 2012, 10:06pm UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/5 "2012-01-18T22:06:15Z")

</div>

No, there isn't. You are using script in the custom filters score, are you  
expecting to be able to use the nested docs values in the script? If so,  
you can't, you will only be able to use the parent doc values.

On Wed, Jan 18, 2012 at 11:58 PM, Arny [arny.ok@googlemail.com](mailto:arny.ok@googlemail.com) wrote:

> I'm using the Java library.  
> Isn't there an example on how to use CustomFiltersScoreQueryBuilder  
> with script on nested objects?
> 
> On Jan 18, 10:30 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > What is the problem? Can you gist a curl example?
> > 
> > On Wed, Jan 18, 2012 at 8:16 PM, Arny [arny...@googlemail.com](mailto:arny...@googlemail.com) wrote:
> > 
> > > Hi,  
> > > is it possible to add scoring on nested filters?  
> > > I can't get it to work.
> > 
> > > Right now I'm using CustomFiltersScoreQueryBuilder and adding  
> > > nestedFilters to it via NestedFilterBuilder.
> > 
> > > Any help appreciated.  
> > > Thanks
> > 
> > > Arny

---

<div class="post-metadata">

**Author:** ![Arny](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@Arny](https://discuss.elastic.co/u/Arny)\
**Post date:** [January 19, 2012, 12:07am UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/6 "2012-01-19T00:07:01Z")

</div>

Oh, that would explain why my score is dropping to zero when I'm  
trying to use script on nested objects.  
Is this hard to implement by ES or why is it not supported?

On Jan 18, 11:06 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> No, there isn't. You are using script in the custom filters score, are you  
> expecting to be able to use the nested docs values in the script? If so,  
> you can't, you will only be able to use the parent doc values.
> 
> On Wed, Jan 18, 2012 at 11:58 PM, Arny [arny...@googlemail.com](mailto:arny...@googlemail.com) wrote:
> 
> > I'm using the Java library.  
> > Isn't there an example on how to use CustomFiltersScoreQueryBuilder  
> > with script on nested objects?
> 
> > On Jan 18, 10:30 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > 
> > > What is the problem? Can you gist a curl example?
> 
> > > On Wed, Jan 18, 2012 at 8:16 PM, Arny [arny...@googlemail.com](mailto:arny...@googlemail.com) wrote:
> > > 
> > > > Hi,  
> > > > is it possible to add scoring on nested filters?  
> > > > I can't get it to work.
> 
> > > > Right now I'm using CustomFiltersScoreQueryBuilder and adding  
> > > > nestedFilters to it via NestedFilterBuilder.
> 
> > > > Any help appreciated.  
> > > > Thanks
> 
> > > > Arny

---

<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:** [January 19, 2012, 6:39pm UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/7 "2012-01-19T18:39:09Z")

</div>

Its just that you can't do it in the custom\_filters\_score, you can use a  
nested query, and have a custom score query in it that will have a script  
that works on values associated with each nested doc.

On Thu, Jan 19, 2012 at 2:07 AM, Arny [arny.ok@googlemail.com](mailto:arny.ok@googlemail.com) wrote:

> Oh, that would explain why my score is dropping to zero when I'm  
> trying to use script on nested objects.  
> Is this hard to implement by ES or why is it not supported?
> 
> On Jan 18, 11:06 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > No, there isn't. You are using script in the custom filters score, are  
> > you  
> > expecting to be able to use the nested docs values in the script? If so,  
> > you can't, you will only be able to use the parent doc values.
> > 
> > On Wed, Jan 18, 2012 at 11:58 PM, Arny [arny...@googlemail.com](mailto:arny...@googlemail.com) wrote:
> > 
> > > I'm using the Java library.  
> > > Isn't there an example on how to use CustomFiltersScoreQueryBuilder  
> > > with script on nested objects?
> > 
> > > On Jan 18, 10:30 pm, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> > > 
> > > > What is the problem? Can you gist a curl example?
> > 
> > > > On Wed, Jan 18, 2012 at 8:16 PM, Arny [arny...@googlemail.com](mailto:arny...@googlemail.com)  
> > > > wrote:
> > > > 
> > > > > Hi,  
> > > > > is it possible to add scoring on nested filters?  
> > > > > I can't get it to work.
> > 
> > > > > Right now I'm using CustomFiltersScoreQueryBuilder and adding  
> > > > > nestedFilters to it via NestedFilterBuilder.
> > 
> > > > > Any help appreciated.  
> > > > > Thanks
> > 
> > > > > Arny

---

<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:42am UTC](https://discuss.elastic.co/t/custom-scoring-on-nested-objects/6431/8 "2017-07-06T03:42:05Z")

</div>


