2

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

4

3 に答える 3

0

音声ベースのアナライザーの観点からは、jonjohnはどちらもまったく同じです。Hibernate Search では、複数のアナライザーを定義できます。複数形のアノテーション@Fieldsを使用して、同じプロパティに複数回インデックスを付けることもできます。

firstname_phonetic とfirstname_standardという名前の 2 つのフィールドで名のインデックスを作成するとします。次に、それぞれを対象とする 2 つの Query インスタンスを作成し、BooleanQuerySHOULD句を使用して 2 つのクエリを組み合わせることができます。これにより、スコアラーは両方のスコアを組み合わせて、完全一致が上位にランク付けされるようになります。

于 2014-04-07T23:28:16.633 に答える
0

回答ありがとうございます。「femtoRgon」の注釈順序を使用し、@Fields (デフォルトおよび音声) を使用して複数のアナライザーを定義しました。これは、クエリを標準と組み合わせ、別のブート値を使用して音声フィールド検索を使用したクエリを組み合わせた場合です (より多くの 2.0f ブート標準で)

助けてくれてありがとう

Br、シェーン

于 2014-04-14T16:26:15.567 に答える