# Use normal and nested fields in same Painless script query?

**URL:** <https://discuss.elastic.co/t/use-normal-and-nested-fields-in-same-painless-script-query/85470>\
**Category:** Elasticsearch\
**Created:** [May 11, 2017, 7:45pm UTC](https://discuss.elastic.co/t/use-normal-and-nested-fields-in-same-painless-script-query/85470 "2017-05-11T19:45:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![PAK90](https://avatars.discourse-cdn.com/v4/letter/p/57b2e6/32.png) [@PAK90](https://discuss.elastic.co/u/PAK90)\
**Post date:** [May 11, 2017, 7:45pm UTC](https://discuss.elastic.co/t/use-normal-and-nested-fields-in-same-painless-script-query/85470/1 "2017-05-11T19:45:53Z")

</div>

I have a mapping like this:

```
{
  printings: { 
    type: "nested",
    properties: {
      prop1: {type: "number"}
    }  
  },
  prop2: {type: "number"}
}

```

I then want to build a Painless query like this:

```
"script": {
          "lang": "painless",
          "inline": "doc['prop1'] > (3 * doc['printings.prop2'])"
        }

```

However testing this in Sense doesn't work. If I replace the nested prop2 with a simple number then it does work. Is there a way to access both root and nested props in a single scripted query? I'm using ES v5.4

---

<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 8, 2017, 7:50pm UTC](https://discuss.elastic.co/t/use-normal-and-nested-fields-in-same-painless-script-query/85470/2 "2017-06-08T19:50:44Z")

</div>

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