Example usage for org.apache.lucene.document DoublePoint setDoubleValue

List of usage examples for org.apache.lucene.document DoublePoint setDoubleValue

Introduction

In this page you can find the example usage for org.apache.lucene.document DoublePoint setDoubleValue.

Prototype

@Override
    public void setDoubleValue(double value) 

Source Link

Usage

From source file:com.vmware.xenon.services.common.LuceneIndexDocumentHelper.java

License:Open Source License

private void addNumericField(String propertyName, double propertyValue, boolean stored,
        boolean isCollectionItem, boolean sorted) {
    long longPropertyValue = NumericUtils.doubleToSortableLong(propertyValue);

    if (stored) {
        Field field = isCollectionItem ? new StoredField(propertyName, propertyValue)
                : getAndSetStoredField(propertyName, propertyValue);
        this.doc.add(field);
    }/*  ww  w . java 2  s.  c  o  m*/

    // DoublePoint adds an index field to the document that allows for efficient search
    // and range queries
    if (isCollectionItem) {
        this.doc.add(new DoublePoint(propertyName, propertyValue));
    } else {
        DoublePoint dpField = this.doublePointFields.computeIfAbsent(propertyName, (k) -> {
            return new DoublePoint(propertyName, propertyValue);
        });
        dpField.setDoubleValue(propertyValue);
        this.doc.add(dpField);
    }

    NumericDocValuesField ndField = getAndSetNumericField(propertyName, longPropertyValue, isCollectionItem);
    this.doc.add(ndField);

    if (sorted) {
        // special handling for groupBy queries
        Field sdField = getAndSetSortedStoredField(propertyName + GROUP_BY_PROPERTY_NAME_SUFFIX,
                Double.toString(propertyValue));
        this.doc.add(sdField);
    }

}