| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.lucene.search.suggest.Lookup
org.apache.lucene.search.suggest.analyzing.AnalyzingInfixSuggester
public class AnalyzingInfixSuggester
Analyzes the input text and then suggests matches based on prefix matches to any tokens in the indexed text. This also highlights the tokens that match.
This just uses an ordinary Lucene index.  It
  supports payloads, and records these as a
  BinaryDocValues field.  Matches are sorted only
  by the suggest weight; it would be nice to support
  blended score + weight sort in the future.  This means
  this suggester best applies when there is a strong
  apriori ranking of all the suggestions.
| Nested Class Summary | 
|---|
| Nested classes/interfaces inherited from class org.apache.lucene.search.suggest.Lookup | 
|---|
| Lookup.LookupPriorityQueue, Lookup.LookupResult | 
| Field Summary | |
|---|---|
| static int | DEFAULT_MIN_PREFIX_CHARSDefault minimum number of leading characters before PrefixQuery is used (4). | 
| protected  IndexSearcher | searcherIndexSearcherused for lookups. | 
| protected static String | TEXT_FIELD_NAMEField name used for the indexed text. | 
| Fields inherited from class org.apache.lucene.search.suggest.Lookup | 
|---|
| CHARSEQUENCE_COMPARATOR | 
| Constructor Summary | |
|---|---|
| AnalyzingInfixSuggester(Version matchVersion,
                        File indexPath,
                        Analyzer analyzer)Create a new instance, loading from a previously built directory, if it exists. | |
| AnalyzingInfixSuggester(Version matchVersion,
                        File indexPath,
                        Analyzer indexAnalyzer,
                        Analyzer queryAnalyzer,
                        int minPrefixChars)Create a new instance, loading from a previously built directory, if it exists. | |
| Method Summary | |
|---|---|
| protected  void | addPrefixMatch(StringBuilder sb,
               String surface,
               String analyzed,
               String prefixToken)Append a matched prefix token, to the provided StringBuilder. | 
| protected  void | addWholeMatch(StringBuilder sb,
              String surface,
              String analyzed)Appends the whole matched token to the provided StringBuilder. | 
|  void | build(TermFreqIterator iter)Builds up a new internal Lookuprepresentation based on the givenTermFreqIterator. | 
|  void | close() | 
| protected  Query | finishQuery(BooleanQuery in,
            boolean allTermsRequired)Subclass can override this to tweak the Query before searching. | 
| protected  Directory | getDirectory(File path)Subclass can override to choose a specific Directoryimplementation. | 
| protected  IndexWriterConfig | getIndexWriterConfig(Version matchVersion,
                     Analyzer indexAnalyzer)Override this to customize index settings, e.g. | 
| protected  Query | getLastTokenQuery(String token)This is called if the last token isn't ended (e.g. | 
|  boolean | load(InputStream out)Discard current lookup data and load it from a previously saved copy. | 
|  List<Lookup.LookupResult> | lookup(CharSequence key,
       boolean onlyMorePopular,
       int num)Look up a key and return possible completion for this key. | 
|  List<Lookup.LookupResult> | lookup(CharSequence key,
       int num,
       boolean allTermsRequired,
       boolean doHighlight)Retrieve suggestions, specifying whether all terms must match ( allTermsRequired) and whether the hits
  should be highlighted (doHighlight). | 
|  boolean | store(OutputStream out)Persist the constructed lookup data to a directory. | 
| Methods inherited from class org.apache.lucene.search.suggest.Lookup | 
|---|
| build | 
| Methods inherited from class java.lang.Object | 
|---|
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
protected static final String TEXT_FIELD_NAME
protected IndexSearcher searcher
IndexSearcher used for lookups.
public static final int DEFAULT_MIN_PREFIX_CHARS
| Constructor Detail | 
|---|
public AnalyzingInfixSuggester(Version matchVersion,
                               File indexPath,
                               Analyzer analyzer)
                        throws IOException
IOException
public AnalyzingInfixSuggester(Version matchVersion,
                               File indexPath,
                               Analyzer indexAnalyzer,
                               Analyzer queryAnalyzer,
                               int minPrefixChars)
                        throws IOException
minPrefixChars - Minimum number of leading characters
     before PrefixQuery is used (default 4).
     Prefixes shorter than this are indexed as character
     ngrams (increasing index size but making lookups
     faster).
IOException| Method Detail | 
|---|
protected IndexWriterConfig getIndexWriterConfig(Version matchVersion,
                                                 Analyzer indexAnalyzer)
protected Directory getDirectory(File path)
                          throws IOException
Directory implementation.
IOException
public void build(TermFreqIterator iter)
           throws IOException
LookupLookup representation based on the given TermFreqIterator.
 The implementation might re-sort the data internally.
build in class LookupIOException
public List<Lookup.LookupResult> lookup(CharSequence key,
                                        boolean onlyMorePopular,
                                        int num)
Lookup
lookup in class Lookupkey - lookup key. Depending on the implementation this may be
 a prefix, misspelling, or even infix.onlyMorePopular - return only more popular resultsnum - maximum number of results to return
protected Query getLastTokenQuery(String token)
                           throws IOException
IOException
public List<Lookup.LookupResult> lookup(CharSequence key,
                                        int num,
                                        boolean allTermsRequired,
                                        boolean doHighlight)
allTermsRequired) and whether the hits
  should be highlighted (doHighlight).
protected Query finishQuery(BooleanQuery in,
                            boolean allTermsRequired)
protected void addWholeMatch(StringBuilder sb,
                             String surface,
                             String analyzed)
StringBuilder.
protected void addPrefixMatch(StringBuilder sb,
                              String surface,
                              String analyzed,
                              String prefixToken)
StringBuilder.
sb - StringBuilder to append tosurface - The fragment of the surface form
        (indexed during build(org.apache.lucene.search.spell.TermFreqIterator), corresponding to
        this matchanalyzed - The analyzed token that matchedprefixToken - The prefix of the token that matchedpublic boolean store(OutputStream out)
Lookup
store in class Lookupout - OutputStream to write the data to.
public boolean load(InputStream out)
Lookup
load in class Lookupout - the InputStream to load the lookup data.
public void close()
           throws IOException
close in interface CloseableIOException| 
 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||