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
Dictionary with terms and optionally payload and optionally contexts information taken from
stored fields in a Lucene index. Similar to
DocumentDictionary
, except it obtains the
weight of the terms in a document based on a LongValuesSource
. 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 LongValuesSource
will likely be obtained using the lucene expression
module. The following example shows how to create a LongValuesSource
from a simple
addition of two fields:
Expression expression = JavascriptCompiler.compile("f1 + f2");
SimpleBindings bindings = new SimpleBindings();
bindings.add(new SortField("f1", SortField.Type.LONG));
bindings.add(new SortField("f2", SortField.Type.LONG));
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
-
Constructor Summary
ConstructorDescriptionDocumentValueSourceDictionary
(IndexReader reader, String field, LongValuesSource weightsValueSource) Creates a new dictionary with the contents of the fields namedfield
for the terms and uses theweightsValueSource
supplied to determine the score.DocumentValueSourceDictionary
(IndexReader reader, String field, LongValuesSource weightsValueSource, String payload) Creates a new dictionary with the contents of the fields namedfield
for the terms,payloadField
for the corresponding payloads and uses theweightsValueSource
supplied 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 namedfield
for the terms,payload
for the corresponding payloads,contexts
for the associated contexts and uses theweightsValueSource
supplied to determine the score. -
Method Summary
Modifier and TypeMethodDescriptionReturns an iterator over all the entries
-
Constructor Details
-
DocumentValueSourceDictionary
public DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource, String payload, String contexts) Creates a new dictionary with the contents of the fields namedfield
for the terms,payload
for the corresponding payloads,contexts
for the associated contexts and uses theweightsValueSource
supplied to determine the score. -
DocumentValueSourceDictionary
public DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource, String payload) Creates a new dictionary with the contents of the fields namedfield
for the terms,payloadField
for the corresponding payloads and uses theweightsValueSource
supplied to determine the score. -
DocumentValueSourceDictionary
public DocumentValueSourceDictionary(IndexReader reader, String field, LongValuesSource weightsValueSource) Creates a new dictionary with the contents of the fields namedfield
for the terms and uses theweightsValueSource
supplied to determine the score.
-
-
Method Details
-
getEntryIterator
Description copied from interface:Dictionary
Returns an iterator over all the entries- Specified by:
getEntryIterator
in interfaceDictionary
- Overrides:
getEntryIterator
in classDocumentDictionary
- Returns:
- Iterator
- Throws:
IOException
-