Class ProtectedTermFilterFactory
java.lang.Object
org.apache.lucene.analysis.AbstractAnalysisFactory
org.apache.lucene.analysis.TokenFilterFactory
org.apache.lucene.analysis.miscellaneous.ConditionalTokenFilterFactory
org.apache.lucene.analysis.miscellaneous.ProtectedTermFilterFactory
- All Implemented Interfaces:
ResourceLoaderAware
Factory for a
ProtectedTermFilter
CustomAnalyzer example:
Analyzer ana = CustomAnalyzer.builder() .withTokenizer("standard") .when("protectedterm", "ignoreCase", "true", "protected", "protectedTerms.txt") .addTokenFilter("truncate", "prefixLength", "4") .addTokenFilter("lowercase") .endwhen() .build();
Solr example, in which conditional filters are specified via the wrappedFilters
parameter - a comma-separated list of case-insensitive TokenFilter SPI names - and conditional
filter args are specified via filterName.argName
parameters:
<fieldType name="reverse_lower_with_exceptions" class="solr.TextField" positionIncrementGap="100"> <analyzer> <tokenizer class="solr.WhitespaceTokenizerFactory"/> <filter class="solr.ProtectedTermFilterFactory" ignoreCase="true" protected="protectedTerms.txt" wrappedFilters="truncate,lowercase" truncate.prefixLength="4" /> </analyzer> </fieldType>
When using the wrappedFilters
parameter, each filter name must be unique, so if
you need to specify the same filter more than once, you must add case-insensitive unique '-id'
suffixes (note that the '-id' suffix is stripped prior to SPI lookup), e.g.:
<fieldType name="double_synonym_with_exceptions" class="solr.TextField" positionIncrementGap="100"> <analyzer> <tokenizer class="solr.WhitespaceTokenizerFactory"/> <filter class="solr.ProtectedTermFilterFactory" ignoreCase="true" protected="protectedTerms.txt" wrappedFilters="synonymgraph-A,synonymgraph-B" synonymgraph-A.synonyms="synonyms-1.txt" synonymgraph-B.synonyms="synonyms-2.txt"/> </analyzer> </fieldType>
See related CustomAnalyzer.Builder.whenTerm(Predicate)
- Since:
- 7.4.0
- SPI Name (case-insensitive: if the name is 'htmlStrip', 'htmlstrip' can be used when looking up the service).
- "protectedTerm"
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
static final char
static final String
static final String
Fields inherited from class org.apache.lucene.analysis.AbstractAnalysisFactory
LUCENE_MATCH_VERSION_PARAM, luceneMatchVersion
-
Constructor Summary
ConstructorDescriptionDefault ctor for compatibility with SPI -
Method Summary
Modifier and TypeMethodDescriptionprotected ConditionalTokenFilter
create
(TokenStream input, Function<TokenStream, TokenStream> inner) Modify the incomingTokenStream
with aConditionalTokenFilter
void
doInform
(ResourceLoader loader) Initialises this component with the correspondingResourceLoader
boolean
Methods inherited from class org.apache.lucene.analysis.miscellaneous.ConditionalTokenFilterFactory
create, inform, setInnerFilters
Methods inherited from class org.apache.lucene.analysis.TokenFilterFactory
availableTokenFilters, findSPIName, forName, lookupClass, normalize, reloadTokenFilters
Methods inherited from class org.apache.lucene.analysis.AbstractAnalysisFactory
defaultCtorException, get, get, get, get, get, getBoolean, getChar, getClassArg, getFloat, getInt, getLines, getLuceneMatchVersion, getOriginalArgs, getPattern, getSet, getSnowballWordSet, getWordSet, isExplicitLuceneMatchVersion, require, require, require, requireBoolean, requireChar, requireFloat, requireInt, setExplicitLuceneMatchVersion, splitAt, splitFileNames
-
Field Details
-
NAME
- See Also:
-
PROTECTED_TERMS
- See Also:
-
FILTER_ARG_SEPARATOR
public static final char FILTER_ARG_SEPARATOR- See Also:
-
FILTER_NAME_ID_SEPARATOR
public static final char FILTER_NAME_ID_SEPARATOR- See Also:
-
-
Constructor Details
-
ProtectedTermFilterFactory
-
ProtectedTermFilterFactory
public ProtectedTermFilterFactory()Default ctor for compatibility with SPI
-
-
Method Details
-
isIgnoreCase
public boolean isIgnoreCase() -
getProtectedTerms
-
create
Description copied from class:ConditionalTokenFilterFactory
Modify the incomingTokenStream
with aConditionalTokenFilter
- Specified by:
create
in classConditionalTokenFilterFactory
-
doInform
Description copied from class:ConditionalTokenFilterFactory
Initialises this component with the correspondingResourceLoader
- Overrides:
doInform
in classConditionalTokenFilterFactory
- Throws:
IOException
-