# Scoring based on nested objects and function score

**URL:** <https://discuss.elastic.co/t/scoring-based-on-nested-objects-and-function-score/28485>\
**Category:** Elasticsearch\
**Created:** [September 2, 2015, 4:27am UTC](https://discuss.elastic.co/t/scoring-based-on-nested-objects-and-function-score/28485 "2015-09-02T04:27:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vineeth\_mohan\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vineeth_mohan_2/32/747_2.png) [@vineeth\_mohan\_2](https://discuss.elastic.co/u/vineeth_mohan_2)\
**Post date:** [September 2, 2015, 4:27am UTC](https://discuss.elastic.co/t/scoring-based-on-nested-objects-and-function-score/28485/1 "2015-09-02T04:27:58Z")

</div>

Hi ,

I have a document like below -  
Here items made nested in the mapings.  
{  
"shopName" : "royal super market",  
"geo": "1.234,2.121",  
"items": [  
{  
"name": "rubber",  
"relevancy": 20  
},  
{  
"name": "pen",  
"relevancy": 10  
}  
]  
}  
Here i want to query on shopName , filter based on certain items and then score document based on geo and matched item names relevancy field.  
I was hoping to push everything to functions in function score query.  
But i cant seem to find anyway to get relevancy field value inside functions function of function\_score.  
Script does not seem to be able to pick values from inside nested object ( that is without touching \_source )

Let me know if there is any method to do this ?

Thanks  
Vineeth

---

<div class="post-metadata">

**Author:** ![remram](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/remram/32/4077_2.png) [@remram](https://discuss.elastic.co/u/remram)\
**Post date:** [September 2, 2015, 5:31am UTC](https://discuss.elastic.co/t/scoring-based-on-nested-objects-and-function-score/28485/2 "2015-09-02T05:31:02Z")

</div>

It's not this what you are looking for?  
[https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-sorting.html](https://www.elastic.co/guide/en/elasticsearch/guide/current/nested-sorting.html)

---

<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 5, 2017, 11:52pm UTC](https://discuss.elastic.co/t/scoring-based-on-nested-objects-and-function-score/28485/3 "2017-07-05T23:52:41Z")

</div>


