Search score of identical documents changes when nested integer attribute is modified

We stumbled upon this issue today and cannot really understand what is happening.
Suppose we have a really simple index with just two documents inside that have the same contents.

// document 1
{
    "question": "text of the question", 
 // nested part 
    "answers": [  
        {
            "text": "text of first answer",
            "clickscore": 0,
        },       
    ]
//
}

// document 2
{
    "question": "text of the question", 
 // nested part 
    "answers": [
        {
            "text": "text of first answer",
            "clickscore": 0,
        },       
    ]
//
}

question and answers.text are Text fields with the same analyzer defined on them. answers is a list with either 1 or many answers inside. clickscore is an Integer field that we will use in the future to boost the relevance of some documents. When we do a search we always look for matches in question and answers.text.

Now the weird part.

document 1 and document 2 have EXACTLY the same content, thus a search on the cluster with text contained in both question and answers.text (for example "text") returns hits with exactly the same score: makes sense.

However, if we update the clickscore of one of the two documents by setting e.g. the document 2 clickscore == 1 and we repeat EXACTLY the same search then the score of the documents are NOT the same.

How is this possible? clickscore is just an integer attribute and it should not affect the score of the search, especially since we're only looking for matches in the Text fields...

Apparently the problem is related to the fact that the shard statistics are not updated on time, and this causes the discrepancy.

If anyone arrives here on this question the only way to fix this is to manually perform a flush, so Index('...').flush() and the scores then are the same again.

1 Like

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