Class DocumentValueSourceDictionary

  • All Implemented Interfaces:

    public class DocumentValueSourceDictionary
    extends DocumentDictionary

    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.

    • 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();