# Get queryNorm factor in script or disable query normalisation at all

**URL:** <https://discuss.elastic.co/t/get-querynorm-factor-in-script-or-disable-query-normalisation-at-all/27802>\
**Category:** Elasticsearch\
**Created:** [August 20, 2015, 9:00pm UTC](https://discuss.elastic.co/t/get-querynorm-factor-in-script-or-disable-query-normalisation-at-all/27802 "2015-08-20T21:00:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JSJS](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@JSJS](https://discuss.elastic.co/u/JSJS)\
**Post date:** [August 20, 2015, 9:00pm UTC](https://discuss.elastic.co/t/get-querynorm-factor-in-script-or-disable-query-normalisation-at-all/27802/1 "2015-08-20T21:00:35Z")

</div>

Hello,

I have the following situation. The Devices are documents, the components nested documents.

```
device_1 (sum_of_component_importance: 3.2)
    component_1 (importance: 1)
    component_2 (importance: 0.5)
    component_3 (importance: 0.2)
    component_4 (importance: 1.5)

device_2 (sum_of_component_importance: 3.3)
    component_1 (importance: 0.3)
    component_3 (importance: 2)
    component_4 (importance: 1)

```

I`m querying the components with a nested query. When I e.g. query for component\_1 and component\_3, the score for the documents should be:

```
device_1: 1.2
device_2: 2.3

```

But it is not, because searching for 2 terms causes the lucene queryNorm factor to be \< 1 and change the score for the found documents.  
This is no problem in most cases , but in my case it is: I want to subtract the importance sum of the NOT found components from the score.

```
device_1: 1.2 - (3.2 - 1.2) = -0.8
device_2: 2.3 - (3.3 - 2.3) = 1.3

```

It is important for me, how high the score for the not hit elements is. But sum\_of\_component\_importance is a precalculated value, and when the score from the modules hits is multiplied by the queryNorm, I can`t just use it without knowing the queryNorm factor.

I see 4 ways to a solution:

1. Disable the queryNorm somehow
2. Get the queryNorm as value in a script to use it in a function\_score query
3. Execute the query two times, and get the queryNorm factor in the first execution. (Is it possible to get the queryNorm after a query was executed?)
4. Find a complete other concept of handling this.

What are your thoughts, can you help me with this issue?

Thank you!

---

<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:54pm UTC](https://discuss.elastic.co/t/get-querynorm-factor-in-script-or-disable-query-normalisation-at-all/27802/2 "2017-07-05T23:54:46Z")

</div>


