Package org.apache.lucene.search.suggest
Class DocumentValueSourceDictionary
- java.lang.Object
-
- org.apache.lucene.search.suggest.DocumentDictionary
-
- org.apache.lucene.search.suggest.DocumentValueSourceDictionary
-
- All Implemented Interfaces:
Dictionary
public class DocumentValueSourceDictionary extends DocumentDictionary
Dictionary with terms and optionally payload and optionally contexts information taken from stored fields in a Lucene index. Similar toDocumentDictionary, except it obtains the weight of the terms in a document based on aLongValuesSource. NOTE:- The term field has to be stored; if it is missing, the document is skipped.
- The payload and contexts field are optional and are not required to be stored.
In practice the
LongValuesSourcewill likely be obtained using the lucene expression module. The following example shows how to create aLongValuesSourcefrom a simple addition of two fields:Expression expression = JavascriptCompiler.compile("f1 + f2"); SimpleBindings bindings = new SimpleBindings(); bindings.add("f1", DoubleValuesSource.fromLongField("f1")); bindings.add("f2", DoubleValuesSource.fromLongField("f2")); LongValuesSource valueSource = expression.getDoubleValuesSource(bindings).toLongValuesSource();
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.lucene.search.suggest.DocumentDictionary
DocumentDictionary.DocumentInputIterator
-
-
Field Summary
-
Fields inherited from class org.apache.lucene.search.suggest.DocumentDictionary
contextsField, payloadField, reader, storedFields
-
-
Constructor Summary
Constructors Constructor Description DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource)Creates a new dictionary with the contents of the fields namedfieldfor the terms and uses theweightsValueSourcesupplied to determine the score.DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource, String payload)Creates a new dictionary with the contents of the fields namedfieldfor the terms,payloadFieldfor the corresponding payloads and uses theweightsValueSourcesupplied to determine the score.DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource, String payload, String contexts)Creates a new dictionary with the contents of the fields namedfieldfor the terms,payloadfor the corresponding payloads,contextsfor the associated contexts and uses theweightsValueSourcesupplied to determine the score.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InputIteratorgetEntryIterator()Returns an iterator over all the entries
-
-
-
Constructor Detail
-
DocumentValueSourceDictionary
public DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource, String payload, String contexts) throws IOException
Creates a new dictionary with the contents of the fields namedfieldfor the terms,payloadfor the corresponding payloads,contextsfor the associated contexts and uses theweightsValueSourcesupplied to determine the score.- Throws:
IOException
-
DocumentValueSourceDictionary
public DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource, String payload) throws IOException
Creates a new dictionary with the contents of the fields namedfieldfor the terms,payloadFieldfor the corresponding payloads and uses theweightsValueSourcesupplied to determine the score.- Throws:
IOException
-
DocumentValueSourceDictionary
public DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource) throws IOException
Creates a new dictionary with the contents of the fields namedfieldfor the terms and uses theweightsValueSourcesupplied to determine the score.- Throws:
IOException
-
-
Method Detail
-
getEntryIterator
public InputIterator getEntryIterator() throws IOException
Description copied from interface:DictionaryReturns an iterator over all the entries- Specified by:
getEntryIteratorin interfaceDictionary- Overrides:
getEntryIteratorin classDocumentDictionary- Returns:
- Iterator
- Throws:
IOException
-
-