문제

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