Search code examples
luceneravendbmorelikethis

Aggregating MoreLikeThis Results in RavenDB


I have been trying out the MoreLikeThis Bundle to bring back a set of documents ordered by the number of matches in a field called 'backyardigans' compared to a key document. This all works as expected.

But what I would like to do is order by the number of matches of 3 separate fields added together.

An example record would be:

var data = new Data{ 
     backyardigans = "Pablo Tasha Uniqua Tyrone Austin",
     engines = "Thomas Percy Henry Toby",
     pigs = "Daddy Peppa George Mummy Granny"
}; 

If another document matched 1 backyardigan 2 engines and 1 pig it would get a score of 4

If another document matched 2 backyardigans 4 engines and 0 pigs it would get a score of 6

These aggregated scores would be the field we would order the results by so they would come back 6,4 and so on.

Is there a way to achieve this with the MoreLikeThis bundle please?


Solution

  • This isn't possible, we use only a single field frequency for this.

    This is important because we need to compare the score on a field basis, and it isn't really possible to compare it on a global basis without taking into account the per fields values.

    Note that this is also a limitation in the underlying Lucene implementation, so there isn't much we can do about it.