I did a simple query on unit test data and the retults come back in the expected order. The query is
+(ancestors:wood name:wood) +(ancestors:screw name:screw)
The data and score is:
- First document (score 0.9944593)
- name : Wood Screws
- ancestors : Screws and fasteners
- Second document (score 0.7294933)
- name : Wood Plugs
- ancestors : Screws and fasteners
- ancestors : Screw Plugs
- Third document (score 0.49740157)
- name : Wood screws
- ancestors : Other products
If I do the same query on production data (~3000 documents), I still get the "only" same three results. But the document score changes the order.
- First document (score 3.9986732)
- name : Wood screws
- ancestors : Other products
- Second document (score 3.9986732)
- name : Wood Screws
- ancestors : Screws and fasteners
- Third document (score 3.7507305)
- name : Wood Plugs
- ancestors : Screws and fasteners
- ancestors : Screw Plugs
The second order seems wrong. Intuitivly, I would have expected the test order to be preserved as documents 2 and 3 both match three word and document 1 only two.
The fact that the first two documents have identical score is also strange. I have also tested 5 other similarity methods and they all give equal scores for the first two documents.
I'm using Lucene 8.5.2 with BM25Similarity and default parameters.
Why does Lucene document "relative score" change from unit test when the same documents are found? How can I improve this scoring issue?