I want to use the power of phonetic searching in hibernate search. The problem is that exact matches are not ranked to the top of the search result. E.g. a search for "john" returns these resultlist:
- jon
- john
- jone
I would have expected 'john' to be listed on top
I defined my Analyzer in the following way:
@AnalyzerDef(name = "phonetic",
tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = StandardFilterFactory.class),
@TokenFilterDef(factory = PhoneticFilterFactory.class, params = {
@Parameter(name = "encoder", value = "DoubleMetaphone"),
@Parameter(name = "inject", value = "true")
})
})
@Analyzer(definition = "phonetic")
public class User{
@Field(index=Index.TOKENIZED, store=Store.YES)
private String firstname;
@Field(index=Index.TOKENIZED, store=Store.YES)
private String lastname;
}
The search is done with this code:
String[] fields = new String[] { "firstname", "lastname" };
MultiFieldQueryParser parser = new MultiFieldQueryParser(fields,
sf.getAnalyzer("phonetic"));
It would be great if you could give me any hint/help, how this ranking yould be achieved. I tried to find something via google, bit i only found out that this has to be implemented by myself using query expansion to boost exact matching more than phonetic search results... Thanking you very much in advance for helping me. I am using Hibernate Search 3.1 together with Solr 1.3
Br, Shane