## org.apache.lucene.search.suggest
Class Lookup

    java.lang.Object
      org.apache.lucene.search.suggest.Lookup

Direct Known Subclasses:
  FSTLookup, JaspellLookup, TSTLookup

    public abstract class Lookup

extends Object

Nested Class Summary
`static class` `Lookup.LookupPriorityQueue`
`static class` `Lookup.LookupResult` Result of a lookup.

Constructor Summary
`Lookup()`

Method Summary
`abstract boolean` `add(String key, Object value)` Modify the lookup data by recording additional data.
`void` `build(Dictionary dict)` Build lookup from a dictionary.
`abstract void` `build(TermFreqIterator tfit)`
`abstract Object` `get(String key)` Get value associated with a specific key.
`abstract boolean` `load(File storeDir)` Discard current lookup data and load it from a previously saved copy.
`abstract List<Lookup.LookupResult>` `lookup(String key, boolean onlyMorePopular, int num)` Look up a key and return possible completion for this key.
`abstract boolean` `store(File storeDir)` Persist the constructed lookup data to a directory.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Lookup

    public Lookup()

Method Detail

### build

    public void build(Dictionary dict)
               throws IOException

  Build lookup from a dictionary. Some implementations may require sorted or unsorted keys from the dictionary's iterator - use `SortedTermFreqIteratorWrapper` or `UnsortedTermFreqIteratorWrapper` in such case.

  Throws:
    `IOException`

### build

    public abstract void build(TermFreqIterator tfit)
                        throws IOException

  Throws:
    `IOException`

### store

    public abstract boolean store(File storeDir)
                           throws IOException

  Persist the constructed lookup data to a directory. Optional operation.

  Parameters:
    `storeDir` - directory where data can be stored.
  Returns:
    true if successful, false if unsuccessful or not supported.
  Throws:
    `IOException` - when fatal IO error occurs.

### load

    public abstract boolean load(File storeDir)
                          throws IOException

  Discard current lookup data and load it from a previously saved copy. Optional operation.

  Parameters:
    `storeDir` - directory where lookup data was stored.
  Returns:
    true if completed successfully, false if unsuccessful or not supported.
  Throws:
    `IOException` - when fatal IO error occurs.

### lookup

    public abstract List<Lookup.LookupResult> lookup(String key,
                                                     boolean onlyMorePopular,
                                                     int num)

  Look up a key and return possible completion for this key.

  Parameters:
    `key` - lookup key. Depending on the implementation this may be a prefix, misspelling, or even infix.
    `onlyMorePopular` - return only more popular results
    `num` - maximum number of results to return
  Returns:
    a list of possible completions, with their relative weight (e.g. popularity)

### add

    public abstract boolean add(String key,
                                Object value)

  Modify the lookup data by recording additional data. Optional operation.

  Parameters:
    `key` - new lookup key
    `value` - value to associate with this key
  Returns:
    true if new key is added, false if it already exists or operation is not supported.

### get

    public abstract Object get(String key)

  Get value associated with a specific key.

  Parameters:
    `key` - lookup key
  Returns:
    associated value

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.