Search in sources :

Example 1 with DoubleDocValues

use of org.apache.lucene.queries.function.docvalues.DoubleDocValues in project elasticsearch by elastic.

the class CountMethodValueSource method getValues.

@Override
// ValueSource uses a rawtype
@SuppressWarnings("rawtypes")
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    final SortedNumericDoubleValues values = leafData.getDoubleValues();
    return new DoubleDocValues(this) {

        @Override
        public double doubleVal(int doc) {
            values.setDocument(doc);
            return values.count();
        }
    };
}
Also used : DoubleDocValues(org.apache.lucene.queries.function.docvalues.DoubleDocValues) SortedNumericDoubleValues(org.elasticsearch.index.fielddata.SortedNumericDoubleValues) AtomicNumericFieldData(org.elasticsearch.index.fielddata.AtomicNumericFieldData)

Example 2 with DoubleDocValues

use of org.apache.lucene.queries.function.docvalues.DoubleDocValues in project elasticsearch by elastic.

the class DateMethodValueSource method getValues.

@Override
// ValueSource uses a rawtype
@SuppressWarnings("rawtypes")
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT);
    NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues(), 0d);
    return new DoubleDocValues(this) {

        @Override
        public double doubleVal(int docId) {
            long millis = (long) docValues.get(docId);
            calendar.setTimeInMillis(millis);
            return calendar.get(calendarType);
        }
    };
}
Also used : Calendar(java.util.Calendar) DoubleDocValues(org.apache.lucene.queries.function.docvalues.DoubleDocValues) NumericDoubleValues(org.elasticsearch.index.fielddata.NumericDoubleValues) AtomicNumericFieldData(org.elasticsearch.index.fielddata.AtomicNumericFieldData)

Example 3 with DoubleDocValues

use of org.apache.lucene.queries.function.docvalues.DoubleDocValues in project elasticsearch by elastic.

the class DateObjectValueSource method getValues.

@Override
// ValueSource uses a rawtype
@SuppressWarnings("rawtypes")
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    MutableDateTime joda = new MutableDateTime(0, DateTimeZone.UTC);
    NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues(), 0d);
    return new DoubleDocValues(this) {

        @Override
        public double doubleVal(int docId) {
            long millis = (long) docValues.get(docId);
            joda.setMillis(millis);
            return function.applyAsInt(joda);
        }
    };
}
Also used : DoubleDocValues(org.apache.lucene.queries.function.docvalues.DoubleDocValues) MutableDateTime(org.joda.time.MutableDateTime) NumericDoubleValues(org.elasticsearch.index.fielddata.NumericDoubleValues) AtomicNumericFieldData(org.elasticsearch.index.fielddata.AtomicNumericFieldData)

Example 4 with DoubleDocValues

use of org.apache.lucene.queries.function.docvalues.DoubleDocValues in project elasticsearch by elastic.

the class EmptyMemberValueSource method getValues.

@Override
// ValueSource uses a rawtype
@SuppressWarnings("rawtypes")
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicNumericFieldData leafData = (AtomicNumericFieldData) fieldData.load(leaf);
    final SortedNumericDoubleValues values = leafData.getDoubleValues();
    return new DoubleDocValues(this) {

        @Override
        public double doubleVal(int doc) {
            values.setDocument(doc);
            if (values.count() == 0) {
                return 1;
            } else {
                return 0;
            }
        }
    };
}
Also used : DoubleDocValues(org.apache.lucene.queries.function.docvalues.DoubleDocValues) SortedNumericDoubleValues(org.elasticsearch.index.fielddata.SortedNumericDoubleValues) AtomicNumericFieldData(org.elasticsearch.index.fielddata.AtomicNumericFieldData)

Example 5 with DoubleDocValues

use of org.apache.lucene.queries.function.docvalues.DoubleDocValues in project elasticsearch by elastic.

the class GeoLatitudeValueSource method getValues.

@Override
// ValueSource uses a rawtype
@SuppressWarnings("rawtypes")
public FunctionValues getValues(Map context, LeafReaderContext leaf) throws IOException {
    AtomicGeoPointFieldData leafData = (AtomicGeoPointFieldData) fieldData.load(leaf);
    final MultiGeoPointValues values = leafData.getGeoPointValues();
    return new DoubleDocValues(this) {

        @Override
        public double doubleVal(int doc) {
            values.setDocument(doc);
            if (values.count() == 0) {
                return 0.0;
            } else {
                return values.valueAt(0).getLat();
            }
        }
    };
}
Also used : AtomicGeoPointFieldData(org.elasticsearch.index.fielddata.AtomicGeoPointFieldData) DoubleDocValues(org.apache.lucene.queries.function.docvalues.DoubleDocValues) MultiGeoPointValues(org.elasticsearch.index.fielddata.MultiGeoPointValues)

Aggregations

DoubleDocValues (org.apache.lucene.queries.function.docvalues.DoubleDocValues)19 FunctionValues (org.apache.lucene.queries.function.FunctionValues)9 AtomicNumericFieldData (org.elasticsearch.index.fielddata.AtomicNumericFieldData)5 Explanation (org.apache.lucene.search.Explanation)3 AtomicGeoPointFieldData (org.elasticsearch.index.fielddata.AtomicGeoPointFieldData)3 MultiGeoPointValues (org.elasticsearch.index.fielddata.MultiGeoPointValues)3 NumericDoubleValues (org.elasticsearch.index.fielddata.NumericDoubleValues)3 ArrayList (java.util.ArrayList)2 MutableValueDouble (org.apache.lucene.util.mutable.MutableValueDouble)2 SortedNumericDoubleValues (org.elasticsearch.index.fielddata.SortedNumericDoubleValues)2 Shape (org.locationtech.spatial4j.shape.Shape)2 Calendar (java.util.Calendar)1 Map (java.util.Map)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 LeafReaderContext (org.apache.lucene.index.LeafReaderContext)1 NumericDocValues (org.apache.lucene.index.NumericDocValues)1 SortedDocValues (org.apache.lucene.index.SortedDocValues)1 SortedSetDocValues (org.apache.lucene.index.SortedSetDocValues)1 SortedSetFieldSource (org.apache.lucene.queries.function.valuesource.SortedSetFieldSource)1 BytesRef (org.apache.lucene.util.BytesRef)1