Search code examples
lucenelucene.netmorelikethis

MoreLikeThis not returning 100% score rate in Lucene.Net when comparing the same document with each other


I don't know if I am calling Lucene.net correctly. I'm trying to call the MoreLikeThis function to compare a document to itself and I'm only getting a score of 0.3174651 where I think I should be getting a score of 1.0. Am I expecting the wrong expect?

This is my code:

                int docId = hits[i].Doc;
                var query2 = mlt.Like(docId);
                TopScoreDocCollector collector = TopScoreDocCollector.Create(100, true);
                searcher.Search(query2, collector);
                ScoreDoc[] hits2 = collector.TopDocs().ScoreDocs;
                var result = new List<string>();
                for (int k = 0; k < hits2.Length; k++)
                {
                    docId = hits2[k].Doc;
                    float score = hits2[k].Score;
                }

Am I doing something wrong please?


Solution

  • The only thing you are doing wrong is thinking that Lucene scores are percentages. They aren't.

    Document scores for a query are to be used to compare the strength of matches within the context of that single query. They are quite effective at sorting results, but they are not percentages, and are not generally suitable for display to a user.