# Non-constant scoring

**URL:** <https://discuss.elastic.co/t/non-constant-scoring/20543>\
**Category:** Elasticsearch\
**Created:** [November 3, 2014, 2:49pm UTC](https://discuss.elastic.co/t/non-constant-scoring/20543 "2014-11-03T14:49:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sofiane\_Cherchalli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sofiane_cherchalli/32/1129_2.png) [@Sofiane\_Cherchalli](https://discuss.elastic.co/u/Sofiane_Cherchalli)\
**Post date:** [November 3, 2014, 2:49pm UTC](https://discuss.elastic.co/t/non-constant-scoring/20543/1 "2014-11-03T14:49:21Z")

</div>

I'm doing a multi\_match query on multi\_fields and I'm expecting a constant  
scoring because the search string is in all the documents. I'm running ES  
1.3.4 with ICU plugin. Here are the steps to reproduce it:

# index settings & mappings

PUT /blogs  
{  
"settings": {  
"analysis": {  
"filter": {  
"length\_filter": {  
"type": "length",  
"min": 2  
}  
},  
"tokenizer": {  
"nGram\_tokenizer": {  
"type": "nGram",  
"min\_gram": 2,  
"max\_gram": 30,  
"token\_chars": ["letter", "digit", "symbol"]  
}  
},  
"analyzer": {  
"nGram\_analyzer": {  
"type": "custom",  
"filter": ["icu\_normalizer", "icu\_folding", "length\_filter"],  
"tokenizer": "nGram\_tokenizer"  
},  
"search\_analyzer": {  
"type": "custom",  
"filter": ["icu\_normalizer", "icu\_folding", "length\_filter"],  
"tokenizer": "icu\_tokenizer"  
},  
"def\_analyzer": {  
"alias": ["icu\_analyzer"],  
"type": "custom",  
"filter": ["icu\_normalizer", "icu\_folding"],  
"tokenizer": "icu\_tokenizer"  
}  
}  
}  
},  
"mappings": {  
"_default_": {  
"\_source": {  
"enabled": true,  
"compress": true,  
"compress\_threshold": "200b"  
},  
"\_all": {  
"enabled": true  
},  
"dynamic\_date\_formats": ["yyyy-MM-dd", "date\_optional\_time"]  
},  
"post": {  
"dynamic": "strict",  
"properties": {  
"title": {  
"type": "string",  
"analyzer": "def\_analyzer",  
"fields": {  
"ngram": {  
"type": "string",  
"analyzer": "nGram\_analyzer",  
"term\_vector": "with\_positions\_offsets"  
}  
}  
},  
"content": {  
"type": "string",  
"analyzer": "def\_analyzer",  
"fields": {  
"ngram": {  
"type": "string",  
"analyzer": "nGram\_analyzer",  
"term\_vector": "with\_positions\_offsets"  
}  
}  
},  
"visible": {  
"type": "boolean",  
"index": "not\_analyzed"  
},  
"post\_date": {  
"type": "date",  
"index": "not\_analyzed"  
}  
}  
}  
}  
}

# index some documents

PUT blogs/post/1  
{  
"title": "title 1",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:50:00"  
}

PUT blogs/post/2  
{  
"title": "title 2",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:51:00"  
}

PUT blogs/post/3  
{  
"title": "title 3",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:52:00"  
}

PUT blogs/post/4  
{  
"title": "title 4",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:53:00"  
}

PUT blogs/post/5  
{  
"title": "title 5",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:54:00"  
}

# run the multi\_match query and sort the results by score (desc) and

post\_date (asc)  
GET /blogs/post/\_search  
{  
"query": {  
"filtered": {  
"query": {  
"multi\_match": {  
"query": "tit",  
"fields": ["title.ngram^2", "content.ngram"],  
"type": "most\_fields",  
"operator": "and",  
"analyzer": "search\_analyzer",  
"minimum\_should\_match" : 1  
}  
},  
"filter": {  
"term": { "visible": "true" }  
}  
}  
},  
"sort" : [  
{ "\_score": { "order": "desc" }},  
{ "post\_date": { "order": "asc" }}  
]  
}

{  
"took": 4,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 5,  
"max\_score": null,  
"hits": [  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "1",  
"\_score": 0.025078464,  
"\_source": {  
"title": "title 1",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:50:00"  
},  
"sort": [  
0.025078464,  
1415019000000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "2",  
"\_score": 0.025078464,  
"\_source": {  
"title": "title 2",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:51:00"  
},  
"sort": [  
0.025078464,  
1415019060000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "3",  
"\_score": 0.025078464,  
"\_source": {  
"title": "title 3",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:52:00"  
},  
"sort": [  
0.025078464,  
1415019120000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "4",  
"\_score": 0.025078464,  
"\_source": {  
"title": "title 4",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:53:00"  
},  
"sort": [  
0.025078464,  
1415019180000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "5",  
"\_score": 0.025078464,  
"\_source": {  
"title": "title 5",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:54:00"  
},  
"sort": [  
0.025078464,  
1415019240000  
]  
}  
]  
}  
}

As you see, the score is uniform (equal) as expected. Now if I add one more  
document, the score changes:

# index one more document

PUT blogs/post/6  
{  
"title": "title 6",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:55:00"  
}

{  
"took": 4,  
"timed\_out": false,  
"\_shards": {  
"total": 5,  
"successful": 5,  
"failed": 0  
},  
"hits": {  
"total": 6,  
"max\_score": null,  
"hits": [  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "1",  
"\_score": _0.053388856_,  
"\_source": {  
"title": "title 1",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:50:00"  
},  
"sort": [  
0.053388856,  
1415019000000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "6",  
"\_score": _0.053388856_,  
"\_source": {  
"title": "title 6",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:55:00"  
},  
"sort": [  
0.053388856,  
1415019300000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "2",  
"\_score": _0.025078464_,  
"\_source": {  
"title": "title 2",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:51:00"  
},  
"sort": [  
0.025078464,  
1415019060000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "3",  
"\_score": _0.025078464_,  
"\_source": {  
"title": "title 3",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:52:00"  
},  
"sort": [  
0.025078464,  
1415019120000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "4",  
"\_score": _0.025078464_,  
"\_source": {  
"title": "title 4",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:53:00"  
},  
"sort": [  
0.025078464,  
1415019180000  
]  
},  
{  
"\_index": "blogs",  
"\_type": "post",  
"\_id": "5",  
"\_score": _0.025078464_,  
"\_source": {  
"title": "title 5",  
"content": "",  
"visible": true,  
"post\_date": "2014-11-03T12:54:00"  
},  
"sort": [  
0.025078464,  
1415019240000  
]  
}  
]  
}  
}

As you could see the score is not anymore constant.

Is this the expected behavior?

--  
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/03f6a68d-6125-48cb-bed9-f7db87499c99%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/03f6a68d-6125-48cb-bed9-f7db87499c99%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:52am UTC](https://discuss.elastic.co/t/non-constant-scoring/20543/2 "2017-07-06T00:52:28Z")

</div>

Closed on July 6, 2017, 12:52am UTC


