# How does Elasticsearch calculate the field-length norm?

**URL:** <https://discuss.elastic.co/t/how-does-elasticsearch-calculate-the-field-length-norm/22913>\
**Category:** Elasticsearch\
**Created:** [March 26, 2015, 5:36am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-calculate-the-field-length-norm/22913 "2015-03-26T05:36:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [March 26, 2015, 5:36am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-calculate-the-field-length-norm/22913/1 "2015-03-26T05:36:38Z")

</div>

Per this post "theory behind relevance  
scoring" [http://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html](http://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html)

Elasticsearch calculate the field-length norm as follows:

norm(d) = 1 / √numTerms

But per my testing, seems the actual result value calculated does not meet above formula.

Following is my index docs:

1. 

{  
"title" : "quick brown fox"  
}

1. 

{  
"title" : "quick fox"  
}

Then I query "fox" with following query:  
POST /vsmtest/test/\_search?explain  
{  
"query" : {  
"match" : {"title":"fox"}  
}  
}

The result norm value are follows:

doc 1:  
{  
"value": 0.5,  
"description": "fieldNorm(doc=0)"  
}  
doc 2:  
{  
"value": 0.625,  
"description": "fieldNorm(doc=0)"  
}

Can anyone help me understand how does 0.5 and 0.625 calculated per the  
formula?  
norm(d) = 1 / √numTerms

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![masaru](https://avatars.discourse-cdn.com/v4/letter/m/a9a28c/32.png) [@masaru](https://discuss.elastic.co/u/masaru)\
**Post date:** [March 27, 2015, 3:02am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-calculate-the-field-length-norm/22913/2 "2015-03-27T03:02:59Z")

</div>

Hi,

I believe it's because field norm is encoded in single byte.  
See [http://lucene.apache.org/core/4\_10\_2/core/org/apache/lucene/search/similarities/DefaultSimilarity.html](http://lucene.apache.org/core/4_10_2/core/org/apache/lucene/search/similarities/DefaultSimilarity.html)

Masaru

On March 26, 2015 at 14:36:45, Xudong You ([xudong.you@gmail.com](mailto:xudong.you@gmail.com)) wrote:

Per this post "theory behind relevance scoring" [http://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html](http://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html)

Elasticsearch calculate the field-length norm as follows:  
norm(d) = 1 / √numTerms

But per my testing, seems the actual result value calculated does not meet above formula.

Following is my index docs:

1. 

{  
"title" : "quick brown fox"  
}

1. 

{  
"title" : "quick fox"  
}

Then I query "fox" with following query:  
POST /vsmtest/test/\_search?explain  
{  
"query" : {  
"match" : {"title":"fox"}  
}  
}

The result norm value are follows:

doc 1:  
{  
"value": 0.5,  
"description": "fieldNorm(doc=0)"  
}  
doc 2:  
{  
"value": 0.625,  
"description": "fieldNorm(doc=0)"  
}

Can anyone help me understand how does 0.5 and 0.625 calculated per the formula?  
norm(d) = 1 / √numTerms

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/etPan.5514c89f.216231b.166%40citra-2.local](https://groups.google.com/d/msgid/elasticsearch/etPan.5514c89f.216231b.166%40citra-2.local).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Youxu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/youxu/32/117375_2.png) [@Youxu](https://discuss.elastic.co/u/Youxu)\
**Post date:** [March 30, 2015, 3:47am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-calculate-the-field-length-norm/22913/3 "2015-03-30T03:47:41Z")

</div>

Thanks Masaru, so it is the precision loss issue by encoding/decoding. That  
makes sense.

On Friday, March 27, 2015 at 11:04:12 AM UTC+8, Masaru Hasegawa wrote:

> Hi,
> 
> I believe it's because field norm is encoded in single byte.  
> See [http://lucene.apache.org/core/4\_10\_2/core/index.html](http://lucene.apache.org/core/4_10_2/core/index.html)  
> [DefaultSimilarity (Lucene 4.10.2 API)](http://lucene.apache.org/core/4_10_2/core/org/apache/lucene/search/similarities/DefaultSimilarity.html)
> 
> [http://lucene.apache.org/core/4\_10\_2/core/index.html](http://lucene.apache.org/core/4_10_2/core/index.html)
> 
> Masaru
> 
> On March 26, 2015 at 14:36:45, Xudong You ([xudon...@gmail.com](mailto:xudon...@gmail.com)  
> \<javascript:\>) wrote:
> 
> Per this post "theory behind relevance scoring"  
> [Theory Behind Relevance Scoring | Elasticsearch: The Definitive Guide [2.x] | Elastic](http://www.elastic.co/guide/en/elasticsearch/guide/current/scoring-theory.html)
> 
> Elasticsearch calculate the field-length norm as follows:
> 
> norm(d) = 1 / √numTerms
> 
> But per my testing, seems the actual result value calculated does not meet above formula.
> 
> Following is my index docs:
> 
> 1. 
> 
> {  
> "title" : "quick brown fox"  
> }
> 
> 1. 
> 
> {  
> "title" : "quick fox"  
> }
> 
> Then I query "fox" with following query:  
> POST /vsmtest/test/\_search?explain  
> {  
> "query" : {  
> "match" : {"title":"fox"}  
> }  
> }
> 
> The result norm value are follows:
> 
> doc 1:  
> {  
> "value": 0.5,  
> "description": "fieldNorm(doc=0)"  
> }  
> doc 2:  
> {  
> "value": 0.625,  
> "description": "fieldNorm(doc=0)"  
> }
> 
> Can anyone help me understand how does 0.5 and 0.625 calculated per the  
> formula?  
> norm(d) = 1 / √numTerms
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/11f6dcea-6704-4a56-93f7-21bf89840789%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/79aae199-a905-4d3c-a764-e0271b9874d9%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/79aae199-a905-4d3c-a764-e0271b9874d9%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 12:23am UTC](https://discuss.elastic.co/t/how-does-elasticsearch-calculate-the-field-length-norm/22913/4 "2017-07-06T00:23:09Z")

</div>


