# Creating a scripted field in nested query

**URL:** <https://discuss.elastic.co/t/creating-a-scripted-field-in-nested-query/231332>\
**Category:** Elasticsearch\
**Created:** [May 6, 2020, 11:46am UTC](https://discuss.elastic.co/t/creating-a-scripted-field-in-nested-query/231332 "2020-05-06T11:46:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![balu\_23](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/balu_23/32/59115_2.png) [@balu\_23](https://discuss.elastic.co/u/balu_23)\
**Post date:** [May 6, 2020, 11:46am UTC](https://discuss.elastic.co/t/creating-a-scripted-field-in-nested-query/231332/1 "2020-05-06T11:46:47Z")

</div>

I have a document like:

```
 > "_index": "nested_obj_demo",

```

> ```
> "_type": "_doc",
> "_id": "1",
> "_score": 1,
> "_source": {
> "price": 125,
> "obj1": [
> {
> "score": 11
> }
> ]
> }
> 
> ```

I want to calculate a function score by multiplying the obj1.score and price value of parent document. I try to create a function score in nested query where I could not able to access parent document price. And also I tried to create a scripted field in nested query that also not working...Any help!!!

---

<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:** [June 3, 2020, 11:58am UTC](https://discuss.elastic.co/t/creating-a-scripted-field-in-nested-query/231332/2 "2020-06-03T11:58:55Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
