Search in sources :

Example 1 with AtomicGeoPointFieldData

use of org.elasticsearch.index.fielddata.AtomicGeoPointFieldData 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)

Example 2 with AtomicGeoPointFieldData

use of org.elasticsearch.index.fielddata.AtomicGeoPointFieldData in project elasticsearch by elastic.

the class GeoLongitudeValueSource 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).getLon();
            }
        }
    };
}
Also used : AtomicGeoPointFieldData(org.elasticsearch.index.fielddata.AtomicGeoPointFieldData) DoubleDocValues(org.apache.lucene.queries.function.docvalues.DoubleDocValues) MultiGeoPointValues(org.elasticsearch.index.fielddata.MultiGeoPointValues)

Example 3 with AtomicGeoPointFieldData

use of org.elasticsearch.index.fielddata.AtomicGeoPointFieldData in project elasticsearch by elastic.

the class GeoEmptyValueSource 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 1;
            } else {
                return 0;
            }
        }
    };
}
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)3 AtomicGeoPointFieldData (org.elasticsearch.index.fielddata.AtomicGeoPointFieldData)3 MultiGeoPointValues (org.elasticsearch.index.fielddata.MultiGeoPointValues)3