If you are using a basic Lucene indexing strategy, you may do something like this:
In this situation, every field in each document will be analyzed using the
The indexer is constrained to using a single analyzer.
In some situations, this may not meet your needs, as you may want to use different analyzers for different fields in a document.
How can we instruct the index writer to use different analyzers for different fields?
PerFieldAnalyzerWrapper does exactly this by letting you populate a Java
Map, which maps document fields to analyzers.
See the documentation here for an overview of how the
You can also use the same approach when building queries
From the docs:
In this example,
StandardAnalyzerwill be used for all fields except “firstname” and “lastname”, for which
KeywordAnalyzerwill be used.
PerFieldAnalyzerWrappercan be used like any other analyzer, for both indexing and query parsing.