You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Chima Echeruo <ce...@mediosystems.com> on 2006/12/20 01:13:40 UTC

Scoring prefix query matches by matching word position

Hello,

Given a prefix query such as "Jame*" and an index containing the
following entries:

Someone that is named James
James Brown
James Crown
John James Mathew
Jameson Jones
Mathew Jamesville
Dewitt Hank James

I'd like Lucene to return the results in the following order:
James Brown
James Crown
Jameson Jones
Mathew Jamesville
Dewitt Hank James
Someone that is named James


The score of a matching document should be inversely proportional to the
position of the word in which the first prefix match occurred. So
documents that matched on the first word should be ranked above matches
in the second word and above matches in the third word etc... Items that
matched on the same word position should then be sorted alphabetically.

So far I've not been successful trying to get this behavior out of the
stock Lucene query parsers and scorers. I'd appreciate any help in
implementing this. The Similarity class does not provide information on
where the match occurred so I cannot implement this logic there.

-c