public class AnalyzingSuggester extends Lookup implements Accountable
 This can result in powerful suggester functionality.  For
 example, if you use an analyzer removing stop words, 
 then the partial text "ghost chr..." could see the
 suggestion "The Ghost of Christmas Past". Note that
 position increments MUST NOT be preserved for this example
 to work, so you should call the constructor with 
 preservePositionIncrements parameter set to 
 false
 
If SynonymFilter is used to map wifi and wireless network to hotspot then the partial text "wirele..." could suggest "wifi router". Token normalization like stemmers, accent removal, etc., would allow suggestions to ignore such variations.
When two matching suggestions have the same weight, they are tie-broken by the analyzed form. If their analyzed form is the same then the order is undefined.
There are some limitations:
StopFilter, and the user will
        type "fast apple", but so far all they've typed is
        "fast a", again because the analyzer doesn't convey whether
        it's seen a token separator after the "a",
        StopFilter will remove that "a" causing
        far more matches than you'd expect.
   Lookup.LookupPriorityQueue, Lookup.LookupResult| Modifier and Type | Field and Description | 
|---|---|
| static int | EXACT_FIRSTInclude this flag in the options parameter to  AnalyzingSuggester(Directory,String,Analyzer,Analyzer,int,int,int,boolean)to always
  return the exact match first, regardless of score. | 
| static int | PRESERVE_SEPInclude this flag in the options parameter to  AnalyzingSuggester(Directory,String,Analyzer,Analyzer,int,int,int,boolean)to preserve
  token separators when matching. | 
CHARSEQUENCE_COMPARATOR| Constructor and Description | 
|---|
| AnalyzingSuggester(Directory tempDir,
                  String tempFileNamePrefix,
                  Analyzer analyzer) | 
| AnalyzingSuggester(Directory tempDir,
                  String tempFileNamePrefix,
                  Analyzer indexAnalyzer,
                  Analyzer queryAnalyzer) | 
| AnalyzingSuggester(Directory tempDir,
                  String tempFileNamePrefix,
                  Analyzer indexAnalyzer,
                  Analyzer queryAnalyzer,
                  int options,
                  int maxSurfaceFormsPerAnalyzedForm,
                  int maxGraphExpansions,
                  boolean preservePositionIncrements)Creates a new suggester. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | build(InputIterator iterator)Builds up a new internal  Lookuprepresentation based on the givenInputIterator. | 
| protected Automaton | convertAutomaton(Automaton a)Used by subclass to change the lookup automaton, if
  necessary. | 
| Object | get(CharSequence key)Returns the weight associated with an input string,
 or null if it does not exist. | 
| Collection<Accountable> | getChildResources() | 
| long | getCount()Get the number of entries the lookup was built with | 
| protected List<FSTUtil.Path<PairOutputs.Pair<Long,BytesRef>>> | getFullPrefixPaths(List<FSTUtil.Path<PairOutputs.Pair<Long,BytesRef>>> prefixPaths,
                  Automaton lookupAutomaton,
                  FST<PairOutputs.Pair<Long,BytesRef>> fst)Returns all prefix paths to initialize the search. | 
| boolean | load(DataInput input)Discard current lookup data and load it from a previously saved copy. | 
| List<Lookup.LookupResult> | lookup(CharSequence key,
      Set<BytesRef> contexts,
      boolean onlyMorePopular,
      int num)Look up a key and return possible completion for this key. | 
| long | ramBytesUsed()Returns byte size of the underlying FST. | 
| boolean | store(DataOutput output)Persist the constructed lookup data to a directory. | 
public static final int EXACT_FIRST
AnalyzingSuggester(Directory,String,Analyzer,Analyzer,int,int,int,boolean) to always
  return the exact match first, regardless of score.  This
  has no performance impact but could result in
  low-quality suggestions.public static final int PRESERVE_SEP
AnalyzingSuggester(Directory,String,Analyzer,Analyzer,int,int,int,boolean) to preserve
  token separators when matching.public AnalyzingSuggester(Directory tempDir, String tempFileNamePrefix, Analyzer analyzer)
public AnalyzingSuggester(Directory tempDir, String tempFileNamePrefix, Analyzer indexAnalyzer, Analyzer queryAnalyzer)
public AnalyzingSuggester(Directory tempDir, String tempFileNamePrefix, Analyzer indexAnalyzer, Analyzer queryAnalyzer, int options, int maxSurfaceFormsPerAnalyzedForm, int maxGraphExpansions, boolean preservePositionIncrements)
indexAnalyzer - Analyzer that will be used for
   analyzing suggestions while building the index.queryAnalyzer - Analyzer that will be used for
   analyzing query text during lookupoptions - see EXACT_FIRST, PRESERVE_SEPmaxSurfaceFormsPerAnalyzedForm - Maximum number of
   surface forms to keep for a single analyzed form.
   When there are too many surface forms we discard the
   lowest weighted ones.maxGraphExpansions - Maximum number of graph paths
   to expand from the analyzed form.  Set this to -1 for
   no limit.preservePositionIncrements - Whether position holes
   should appear in the automatapublic long ramBytesUsed()
ramBytesUsed in interface Accountablepublic Collection<Accountable> getChildResources()
getChildResources in interface Accountableprotected Automaton convertAutomaton(Automaton a)
public void build(InputIterator iterator) throws IOException
LookupLookup representation based on the given InputIterator.
 The implementation might re-sort the data internally.build in class LookupIOExceptionpublic boolean store(DataOutput output) throws IOException
Lookupstore in class Lookupoutput - DataOutput to write the data to.IOException - when fatal IO error occurs.public boolean load(DataInput input) throws IOException
Lookupload in class Lookupinput - the DataInput to load the lookup data.IOException - when fatal IO error occurs.public List<Lookup.LookupResult> lookup(CharSequence key, Set<BytesRef> contexts, boolean onlyMorePopular, int num)
Lookuplookup in class Lookupkey - lookup key. Depending on the implementation this may be
 a prefix, misspelling, or even infix.contexts - contexts to filter the lookup by, or null if all contexts are allowed; if the suggestion contains any of the contexts, it's a matchonlyMorePopular - return only more popular resultsnum - maximum number of results to returnpublic long getCount()
Lookupprotected List<FSTUtil.Path<PairOutputs.Pair<Long,BytesRef>>> getFullPrefixPaths(List<FSTUtil.Path<PairOutputs.Pair<Long,BytesRef>>> prefixPaths, Automaton lookupAutomaton, FST<PairOutputs.Pair<Long,BytesRef>> fst) throws IOException
IOExceptionpublic Object get(CharSequence key)
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.