質問

How do I use multiple analyzers for a single field in my Java class?

For example, currently my class looks like this:

public class User {
   @AnalyzerDef(name = "my_analyzer",
        tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
        filters = {...
   })
   @Analyzer(definition = "my_analyzer")
   private String name;
}

I would like to define another analyzer on the name field.

役に立ちましたか?

解決

You need to use @Fields on the property, specifying an array if @Field annotations. Each @Field in turn can specify its own analyzer via the analyzer property.

You cannot specify multiple top level analyzer for a single field. Of course within a @AnalyzerDef you are free to assemble filters as you like to customize the analyzer behaviour.

What makes most sense will depend on the use case.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top