Java Code Examples for org.elasticsearch.common.geo.ShapeRelation#DISJOINT

The following examples show how to use org.elasticsearch.common.geo.ShapeRelation#DISJOINT . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoUtils.java    From elasticsearch-sql with MIT License 6 votes vote down vote up
public static ShapeRelation parseGeoRelation(int relation){
    switch (relation){
        case ElasticsearchParser.WITHIN:{
            return ShapeRelation.WITHIN;
        }
        case ElasticsearchParser.DISJOINT:{
            return ShapeRelation.DISJOINT;
        }
        case ElasticsearchParser.CONTAINS:{
            return ShapeRelation.CONTAINS;
        }
        default:
        case ElasticsearchParser.INTERSECTS:{
            return ShapeRelation.INTERSECTS;
        }
    }
}
 
Example 2
Source File: ElasticsearchIndex.java    From rdf4j with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private ShapeRelation toSpatialOp(String relation) {
	if (GEOF.SF_INTERSECTS.stringValue().equals(relation)) {
		return ShapeRelation.INTERSECTS;
	}
	if (GEOF.SF_DISJOINT.stringValue().equals(relation)) {
		return ShapeRelation.DISJOINT;
	}
	if (GEOF.EH_COVERED_BY.stringValue().equals(relation)) {
		return ShapeRelation.WITHIN;
	}
	return null;
}
 
Example 3
Source File: DateFieldMapper.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public Query rangeQuery(Object lowerTerm,
                        Object upperTerm,
                        boolean includeLower,
                        boolean includeUpper,
                        ShapeRelation relation,
                        @Nullable DateTimeZone timeZone,
                        QueryShardContext context) {
    failIfNotIndexed();
    if (relation == ShapeRelation.DISJOINT) {
        throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() +
                "] does not support DISJOINT ranges");
    }
    long l, u;
    if (lowerTerm == null) {
        l = Long.MIN_VALUE;
    } else {
        l = (Long) lowerTerm;
        if (includeLower == false) {
            ++l;
        }
    }
    if (upperTerm == null) {
        u = Long.MAX_VALUE;
    } else {
        u = (Long) upperTerm;
        if (includeUpper == false) {
            --u;
        }
    }
    Query query = LongPoint.newRangeQuery(name(), l, u);
    if (hasDocValues()) {
        Query dvQuery = SortedNumericDocValuesField.newSlowRangeQuery(name(), l, u);
        query = new IndexOrDocValuesQuery(query, dvQuery);
    }
    return query;
}
 
Example 4
Source File: SimpleMappedFieldType.java    From crate with Apache License 2.0 5 votes vote down vote up
@Override
public final Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower, boolean includeUpper,
                              ShapeRelation relation, DateTimeZone timeZone, QueryShardContext context) {
    if (relation == ShapeRelation.DISJOINT) {
        throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() +
                "] does not support DISJOINT ranges");
    }
    // We do not fail on non-null time zones and date parsers
    // The reasoning is that on query parsers, you might want to set a time zone or format for date fields
    // but then the API has no way to know which fields are dates and which fields are not dates
    return rangeQuery(lowerTerm, upperTerm, includeLower, includeUpper, context);
}