Wednesday, September 23, 2009

Why is Lucene MoreLikeThis Final?

Lucene has a class MoreLikeThis which can used to build a search query finding documents similar to a passed example document.

This is very useful; in my RSS reader I allows users to find articles similar to an article they find interesting.

I'd like to do something a bit advanced: given an instance of class A, find similar instances of class B. The two classes are stored in separate Lucene indices; the vast majority of the time they are to be queried separately.

For some reason they have chosen to implement MoreLikeThis as final. I can't see any reason for this. I'd like to be able to extend it to add a new public Query like... method but no dice. The primary methods I need (createQuery()) to call are private so there doesn't seem to be a way around it:

I'll need to make my own version of the whole class. Ick. Looking at it positively, this will encourage me to learn the internals of the class instead of using it as a black box.

No comments:

Post a Comment