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 information taken from stored fields in a Lucene index. Similar to
NOTE:DocumentDictionary, except it obtains the weight of the terms in a document based on aValueSource.- The term and (optionally) payload fields have to be stored
- if the term or (optionally) payload fields supplied do not have a value for a document, then the document is rejected by the dictionary
In practice the
ValueSourcewill likely be obtained using the lucene expression module. The following example shows how to create aValueSourcefrom 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)); ValueSource valueSource = expression.getValueSource(bindings);
-
-
Constructor Summary
Constructors Constructor Description DocumentValueSourceDictionary(IndexReader reader, java.lang.String field, ValueSource weightsValueSource)Creates a new dictionary with the contents of the fields namedfieldfor the terms and uses theweightsValueSourcesupplied to determine the score.DocumentValueSourceDictionary(IndexReader reader, java.lang.String field, ValueSource weightsValueSource, java.lang.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.
-
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, java.lang.String field, ValueSource weightsValueSource, java.lang.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
public DocumentValueSourceDictionary(IndexReader reader, java.lang.String field, ValueSource weightsValueSource)
Creates a new dictionary with the contents of the fields namedfieldfor the terms and uses theweightsValueSourcesupplied to determine the score.
-
-
Method Detail
-
getEntryIterator
public InputIterator getEntryIterator() throws java.io.IOException
Description copied from interface:DictionaryReturns an iterator over all the entries- Specified by:
getEntryIteratorin interfaceDictionary- Overrides:
getEntryIteratorin classDocumentDictionary- Returns:
- Iterator
- Throws:
java.io.IOException
-
-