# How does fieldNorm calculated in the example

**URL:** <https://discuss.elastic.co/t/how-does-fieldnorm-calculated-in-the-example/54732>\
**Category:** Elasticsearch\
**Created:** [July 5, 2016, 12:51pm UTC](https://discuss.elastic.co/t/how-does-fieldnorm-calculated-in-the-example/54732 "2016-07-05T12:51:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![duo\_yi](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@duo\_yi](https://discuss.elastic.co/u/duo_yi)\
**Post date:** [July 5, 2016, 12:51pm UTC](https://discuss.elastic.co/t/how-does-fieldnorm-calculated-in-the-example/54732/1 "2016-07-05T12:51:30Z")

</div>

Hi,

I saw the explanation of field-norm is: norm(d) = 1 / √numTerms, and in the "put it together" section in the following page:  
[https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html#\_putting\_it\_together](https://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html#_putting_it_together)

it gave one example:  
doc(and the only doc in the corpus) is "quick brown fox"  
query is "fox"

however, the fieldNorm in this case is "0.5". As I understand it, the norm should be 1/√3, as 3 terms are there in the "quick brown fox".

Can someone tell me how this o.5 comes from?

Thanks ahead

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [July 5, 2016, 1:15pm UTC](https://discuss.elastic.co/t/how-does-fieldnorm-calculated-in-the-example/54732/2 "2016-07-05T13:15:01Z")

</div>

Hi @duo_yi,

interesting question. 🙂

You can see the formula directly in the [Lucene source code](https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/search/similarities/ClassicSimilarity.java#L67-L69).

If you calculate the value using the formula, you get norm("quick brown fox") = 1 / √3 = 0.57735

However, this would be way to wasteful to store this value in the index. So Lucene uses another trick and reduces the precision. You can see the [respective method](https://github.com/apache/lucene-solr/blob/master/lucene/core/src/java/org/apache/lucene/search/similarities/ClassicSimilarity.java#L86-L88) a few lines below.

If you try to encode and decode the value using the following snippet you get exactly 0.5 (which is a sufficient precision for this purpose):

```auto
SmallFloat.byte315ToFloat(SmallFloat.floatToByte315(0.57735026918963f))

```

Daniel

---

<div class="post-metadata">

**Author:** ![duo\_yi](https://avatars.discourse-cdn.com/v4/letter/d/ba9def/32.png) [@duo\_yi](https://discuss.elastic.co/u/duo_yi)\
**Post date:** [August 31, 2016, 7:03am UTC](https://discuss.elastic.co/t/how-does-fieldnorm-calculated-in-the-example/54732/3 "2016-08-31T07:03:05Z")

</div>

Hi Denial,

Thanks so much for the reply.

I found the encode-decode explanation as well, but I forgot to withdraw the question.

Still much thanks for your response. Hope it would help others who have same question.

---

<div class="post-metadata">

**Author:** ![danielmitterdorfer](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/danielmitterdorfer/32/110510_2.png) [@danielmitterdorfer](https://discuss.elastic.co/u/danielmitterdorfer)\
**Post date:** [August 31, 2016, 7:42am UTC](https://discuss.elastic.co/t/how-does-fieldnorm-calculated-in-the-example/54732/4 "2016-08-31T07:42:48Z")

</div>

No worries @duo_yi. 🙂

---

<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, 10:23pm UTC](https://discuss.elastic.co/t/how-does-fieldnorm-calculated-in-the-example/54732/5 "2017-07-05T22:23:43Z")

</div>


