Package org.apache.lucene.analysis.path
Class PathHierarchyTokenizerFactory
- java.lang.Object
-
- org.apache.lucene.analysis.AbstractAnalysisFactory
-
- org.apache.lucene.analysis.TokenizerFactory
-
- org.apache.lucene.analysis.path.PathHierarchyTokenizerFactory
-
public class PathHierarchyTokenizerFactory extends TokenizerFactory
Factory forPathHierarchyTokenizer
.This factory is typically configured for use only in the
index
Analyzer (or only in thequery
Analyzer, but never both).For example, in the configuration below a query for
Books/NonFic
will match documents indexed with values likeBooks/NonFic
,Books/NonFic/Law
,Books/NonFic/Science/Physics
, etc. But it will not match documents indexed with values likeBooks
, orBooks/Fic
...<fieldType name="descendent_path" class="solr.TextField"> <analyzer type="index"> <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" /> </analyzer> <analyzer type="query"> <tokenizer class="solr.KeywordTokenizerFactory" /> </analyzer> </fieldType>
In this example however we see the oposite configuration, so that a query for
Books/NonFic/Science/Physics
would match documents containingBooks/NonFic
,Books/NonFic/Science
, orBooks/NonFic/Science/Physics
, but notBooks/NonFic/Science/Physics/Theory
orBooks/NonFic/Law
.<fieldType name="descendent_path" class="solr.TextField"> <analyzer type="index"> <tokenizer class="solr.KeywordTokenizerFactory" /> </analyzer> <analyzer type="query"> <tokenizer class="solr.PathHierarchyTokenizerFactory" delimiter="/" /> </analyzer> </fieldType>
- Since:
- 3.1
-
-
Field Summary
Fields Modifier and Type Field Description private char
delimiter
static java.lang.String
NAME
SPI nameprivate char
replacement
private boolean
reverse
private int
skip
-
Fields inherited from class org.apache.lucene.analysis.AbstractAnalysisFactory
LUCENE_MATCH_VERSION_PARAM, luceneMatchVersion
-
-
Constructor Summary
Constructors Constructor Description PathHierarchyTokenizerFactory()
Default ctor for compatibility with SPIPathHierarchyTokenizerFactory(java.util.Map<java.lang.String,java.lang.String> args)
Creates a new PathHierarchyTokenizerFactory
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tokenizer
create(AttributeFactory factory)
Creates a TokenStream of the specified input using the given AttributeFactory-
Methods inherited from class org.apache.lucene.analysis.TokenizerFactory
availableTokenizers, create, findSPIName, forName, lookupClass, reloadTokenizers
-
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 Detail
-
NAME
public static final java.lang.String NAME
SPI name- See Also:
- Constant Field Values
-
delimiter
private final char delimiter
-
replacement
private final char replacement
-
reverse
private final boolean reverse
-
skip
private final int skip
-
-
Method Detail
-
create
public Tokenizer create(AttributeFactory factory)
Description copied from class:TokenizerFactory
Creates a TokenStream of the specified input using the given AttributeFactory- Specified by:
create
in classTokenizerFactory
-
-