Class DirectCandidateGenerator
- java.lang.Object
-
- org.elasticsearch.search.suggest.phrase.CandidateGenerator
-
- org.elasticsearch.search.suggest.phrase.DirectCandidateGenerator
-
public final class DirectCandidateGenerator extends CandidateGenerator
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDirectCandidateGenerator.Candidatestatic classDirectCandidateGenerator.CandidateSetstatic classDirectCandidateGenerator.TokenConsumer
-
Constructor Summary
Constructors Constructor Description DirectCandidateGenerator(org.apache.lucene.search.spell.DirectSpellChecker spellchecker, java.lang.String field, org.apache.lucene.search.spell.SuggestMode suggestMode, org.apache.lucene.index.IndexReader reader, double nonErrorLikelihood, int numCandidates)DirectCandidateGenerator(org.apache.lucene.search.spell.DirectSpellChecker spellchecker, java.lang.String field, org.apache.lucene.search.spell.SuggestMode suggestMode, org.apache.lucene.index.IndexReader reader, double nonErrorLikelihood, int numCandidates, org.apache.lucene.analysis.Analyzer preFilter, org.apache.lucene.analysis.Analyzer postFilter, org.apache.lucene.index.Terms terms)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intanalyze(org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.util.BytesRef toAnalyze, java.lang.String field, DirectCandidateGenerator.TokenConsumer consumer, org.apache.lucene.util.CharsRefBuilder spare)static intanalyze(org.apache.lucene.analysis.TokenStream stream, DirectCandidateGenerator.TokenConsumer consumer)NOTE: this method closes the TokenStream, even on exception, which is awkward because really the caller who calledAnalyzer.tokenStream(java.lang.String, java.io.Reader)should close it, but when trying that there are recursion issues when we try to use the same TokenStream twice in the same recursion...DirectCandidateGenerator.CandidatecreateCandidate(org.apache.lucene.util.BytesRef term, long frequency, double channelScore, boolean userInput)DirectCandidateGenerator.CandidateSetdrawCandidates(DirectCandidateGenerator.CandidateSet set)longfrequency(org.apache.lucene.util.BytesRef term)java.lang.StringgetField()longinternalFrequency(org.apache.lucene.util.BytesRef term)booleanisKnownWord(org.apache.lucene.util.BytesRef term)protected voidpostFilter(DirectCandidateGenerator.Candidate candidate, org.apache.lucene.util.CharsRefBuilder spare, org.apache.lucene.util.BytesRefBuilder byteSpare, java.util.List<DirectCandidateGenerator.Candidate> candidates)protected org.apache.lucene.util.BytesRefpreFilter(org.apache.lucene.util.BytesRef term, org.apache.lucene.util.CharsRefBuilder spare, org.apache.lucene.util.BytesRefBuilder byteSpare)protected longthresholdFrequency(long termFrequency, long dictionarySize)-
Methods inherited from class org.elasticsearch.search.suggest.phrase.CandidateGenerator
createCandidate, createCandidate, drawCandidates
-
-
-
-
Constructor Detail
-
DirectCandidateGenerator
public DirectCandidateGenerator(org.apache.lucene.search.spell.DirectSpellChecker spellchecker, java.lang.String field, org.apache.lucene.search.spell.SuggestMode suggestMode, org.apache.lucene.index.IndexReader reader, double nonErrorLikelihood, int numCandidates) throws java.io.IOException- Throws:
java.io.IOException
-
DirectCandidateGenerator
public DirectCandidateGenerator(org.apache.lucene.search.spell.DirectSpellChecker spellchecker, java.lang.String field, org.apache.lucene.search.spell.SuggestMode suggestMode, org.apache.lucene.index.IndexReader reader, double nonErrorLikelihood, int numCandidates, org.apache.lucene.analysis.Analyzer preFilter, org.apache.lucene.analysis.Analyzer postFilter, org.apache.lucene.index.Terms terms) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Detail
-
isKnownWord
public boolean isKnownWord(org.apache.lucene.util.BytesRef term) throws java.io.IOException- Specified by:
isKnownWordin classCandidateGenerator- Throws:
java.io.IOException
-
frequency
public long frequency(org.apache.lucene.util.BytesRef term) throws java.io.IOException- Specified by:
frequencyin classCandidateGenerator- Throws:
java.io.IOException
-
internalFrequency
public long internalFrequency(org.apache.lucene.util.BytesRef term) throws java.io.IOException- Throws:
java.io.IOException
-
getField
public java.lang.String getField()
-
drawCandidates
public DirectCandidateGenerator.CandidateSet drawCandidates(DirectCandidateGenerator.CandidateSet set) throws java.io.IOException
- Specified by:
drawCandidatesin classCandidateGenerator- Throws:
java.io.IOException
-
preFilter
protected org.apache.lucene.util.BytesRef preFilter(org.apache.lucene.util.BytesRef term, org.apache.lucene.util.CharsRefBuilder spare, org.apache.lucene.util.BytesRefBuilder byteSpare) throws java.io.IOException- Throws:
java.io.IOException
-
postFilter
protected void postFilter(DirectCandidateGenerator.Candidate candidate, org.apache.lucene.util.CharsRefBuilder spare, org.apache.lucene.util.BytesRefBuilder byteSpare, java.util.List<DirectCandidateGenerator.Candidate> candidates) throws java.io.IOException
- Throws:
java.io.IOException
-
thresholdFrequency
protected long thresholdFrequency(long termFrequency, long dictionarySize)
-
createCandidate
public DirectCandidateGenerator.Candidate createCandidate(org.apache.lucene.util.BytesRef term, long frequency, double channelScore, boolean userInput) throws java.io.IOException
- Specified by:
createCandidatein classCandidateGenerator- Throws:
java.io.IOException
-
analyze
public static int analyze(org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.util.BytesRef toAnalyze, java.lang.String field, DirectCandidateGenerator.TokenConsumer consumer, org.apache.lucene.util.CharsRefBuilder spare) throws java.io.IOException- Throws:
java.io.IOException
-
analyze
public static int analyze(org.apache.lucene.analysis.TokenStream stream, DirectCandidateGenerator.TokenConsumer consumer) throws java.io.IOExceptionNOTE: this method closes the TokenStream, even on exception, which is awkward because really the caller who calledAnalyzer.tokenStream(java.lang.String, java.io.Reader)should close it, but when trying that there are recursion issues when we try to use the same TokenStream twice in the same recursion...- Throws:
java.io.IOException
-
-