Reputation: 21275
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.
Upvotes: 0
Views: 345
Reputation: 19129
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.
Upvotes: 1