|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.lucene.analysis.Analyzer org.apache.lucene.analysis.MockAnalyzer
public final class MockAnalyzer
Analyzer for testing
This analyzer is a replacement for Whitespace/Simple/KeywordAnalyzers for unit tests. If you are testing a custom component such as a queryparser or analyzer-wrapper that consumes analysis streams, its a great idea to test it with this analyzer instead. MockAnalyzer has the following behavior:
MockTokenizer
are turned on for extra
checks that the consumer is consuming properly. These checks can be disabled
with setEnableChecks(boolean)
.
MockTokenizer
Constructor Summary | |
---|---|
MockAnalyzer(Random random)
Create a Whitespace-lowercasing analyzer with no stopwords removal. |
|
MockAnalyzer(Random random,
int pattern,
boolean lowerCase)
Calls MockAnalyzer(random, pattern, lowerCase, CharArraySet.EMPTY_STOPSET, false ). |
|
MockAnalyzer(Random random,
int pattern,
boolean lowerCase,
CharArraySet filter,
boolean enablePositionIncrements)
Creates a new MockAnalyzer. |
Method Summary | |
---|---|
int |
getPositionIncrementGap(String fieldName)
Invoked before indexing a Fieldable instance if terms have already been added to that field. |
TokenStream |
reusableTokenStream(String fieldName,
Reader reader)
Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method. |
void |
setEnableChecks(boolean enableChecks)
Toggle consumer workflow checking: if your test consumes tokenstreams normally you should leave this enabled. |
void |
setMaxTokenLength(int length)
Toggle maxTokenLength for MockTokenizer |
void |
setPositionIncrementGap(int positionIncrementGap)
|
TokenStream |
tokenStream(String fieldName,
Reader reader)
Creates a TokenStream which tokenizes all the text in the provided Reader. |
Methods inherited from class org.apache.lucene.analysis.Analyzer |
---|
close, getOffsetGap, getPreviousTokenStream, setPreviousTokenStream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MockAnalyzer(Random random, int pattern, boolean lowerCase, CharArraySet filter, boolean enablePositionIncrements)
random
- Random for payloads behaviorpattern
- pattern constant describing how tokenization should happenlowerCase
- true if the tokenizer should lowercase termsfilter
- CharArraySet describing how terms should be filtered (set of stopwords, etc)enablePositionIncrements
- true if position increments should reflect filtered terms.public MockAnalyzer(Random random, int pattern, boolean lowerCase)
MockAnalyzer(random, pattern, lowerCase, CharArraySet.EMPTY_STOPSET, false
).
public MockAnalyzer(Random random)
Calls MockAnalyzer(random, MockTokenizer.WHITESPACE, true)
.
Method Detail |
---|
public TokenStream tokenStream(String fieldName, Reader reader)
Analyzer
tokenStream
in class Analyzer
public TokenStream reusableTokenStream(String fieldName, Reader reader) throws IOException
Analyzer
reusableTokenStream
in class Analyzer
IOException
public void setPositionIncrementGap(int positionIncrementGap)
public int getPositionIncrementGap(String fieldName)
Analyzer
getPositionIncrementGap
in class Analyzer
fieldName
- Fieldable name being indexed.
Analyzer.tokenStream(String,Reader)
public void setEnableChecks(boolean enableChecks)
public void setMaxTokenLength(int length)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |