/** * Defines which spatial strategy will be used for building the geo shape * Query. When not set, the strategy that will be used will be the one that * is associated with the geo shape field in the mappings. * * @param strategy * The spatial strategy to use for building the geo shape Query * @return this */ public GeoShapeQueryBuilder strategy(SpatialStrategy strategy) { if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.strategy = strategy; return this; }
/** * Sets the relation of query shape and indexed shape. * * @param relation relation of the shapes * @return this */ public GeoShapeQueryBuilder relation(ShapeRelation relation) { if (relation == null) { throw new IllegalArgumentException("No Shape Relation defined"); } if (SpatialStrategy.TERM.equals(strategy) && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("current strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.relation = relation; return this; }
@Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME); builder.startObject(fieldName); builder.field(FROM_FIELD.getPreferredName(), maybeConvertToString(this.from)); builder.field(TO_FIELD.getPreferredName(), maybeConvertToString(this.to)); builder.field(INCLUDE_LOWER_FIELD.getPreferredName(), includeLower); builder.field(INCLUDE_UPPER_FIELD.getPreferredName(), includeUpper); if (timeZone != null) { builder.field(TIME_ZONE_FIELD.getPreferredName(), timeZone.getID()); } if (format != null) { builder.field(FORMAT_FIELD.getPreferredName(), format.pattern()); } if (relation != null) { builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName()); } printBoostAndQueryName(builder); builder.endObject(); builder.endObject(); }
builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName());
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(this.fieldName); out.writeGenericValue(this.from); out.writeGenericValue(this.to); out.writeBoolean(this.includeLower); out.writeBoolean(this.includeUpper); out.writeOptionalTimeZone(timeZone); String formatString = null; if (this.format != null) { formatString = this.format.pattern(); } out.writeOptionalString(formatString); if (out.getVersion().onOrAfter(Version.V_5_2_0)) { String relationString = null; if (this.relation != null) { relationString = this.relation.getRelationName(); } out.writeOptionalString(relationString); } }
/** * Defines which spatial strategy will be used for building the geo shape * Query. When not set, the strategy that will be used will be the one that * is associated with the geo shape field in the mappings. * * @param strategy * The spatial strategy to use for building the geo shape Query * @return this */ public GeoShapeQueryBuilder strategy(SpatialStrategy strategy) { if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.strategy = strategy; return this; }
/** * Defines which spatial strategy will be used for building the geo shape * Query. When not set, the strategy that will be used will be the one that * is associated with the geo shape field in the mappings. * * @param strategy * The spatial strategy to use for building the geo shape Query * @return this */ public GeoShapeQueryBuilder strategy(SpatialStrategy strategy) { if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.strategy = strategy; return this; }
/** * Sets the relation of query shape and indexed shape. * * @param relation relation of the shapes * @return this */ public GeoShapeQueryBuilder relation(ShapeRelation relation) { if (relation == null) { throw new IllegalArgumentException("No Shape Relation defined"); } if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("current strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.relation = relation; return this; }
/** * Defines which spatial strategy will be used for building the geo shape * Query. When not set, the strategy that will be used will be the one that * is associated with the geo shape field in the mappings. * * @param strategy * The spatial strategy to use for building the geo shape Query * @return this */ public GeoShapeQueryBuilder strategy(SpatialStrategy strategy) { if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.strategy = strategy; return this; }
/** * Sets the relation of query shape and indexed shape. * * @param relation relation of the shapes * @return this */ public GeoShapeQueryBuilder relation(ShapeRelation relation) { if (relation == null) { throw new IllegalArgumentException("No Shape Relation defined"); } if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("current strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.relation = relation; return this; }
/** * Sets the relation of query shape and indexed shape. * * @param relation relation of the shapes * @return this */ public GeoShapeQueryBuilder relation(ShapeRelation relation) { if (relation == null) { throw new IllegalArgumentException("No Shape Relation defined"); } if (strategy != null && strategy == SpatialStrategy.TERM && relation != ShapeRelation.INTERSECTS) { throw new IllegalArgumentException("current strategy [" + strategy.getStrategyName() + "] only supports relation [" + ShapeRelation.INTERSECTS.getRelationName() + "] found relation [" + relation.getRelationName() + "]"); } this.relation = relation; return this; }
@Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME); builder.startObject(fieldName); if (strategy != null) { builder.field(STRATEGY_FIELD.getPreferredName(), strategy.getStrategyName()); } if (shape != null) { builder.field(SHAPE_FIELD.getPreferredName()); shape.toXContent(builder, params); } else { builder.startObject(INDEXED_SHAPE_FIELD.getPreferredName()) .field(SHAPE_ID_FIELD.getPreferredName(), indexedShapeId) .field(SHAPE_TYPE_FIELD.getPreferredName(), indexedShapeType); if (indexedShapeIndex != null) { builder.field(SHAPE_INDEX_FIELD.getPreferredName(), indexedShapeIndex); } if (indexedShapePath != null) { builder.field(SHAPE_PATH_FIELD.getPreferredName(), indexedShapePath); } builder.endObject(); } if(relation != null) { builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName()); } builder.endObject(); builder.field(IGNORE_UNMAPPED_FIELD.getPreferredName(), ignoreUnmapped); printBoostAndQueryName(builder); builder.endObject(); }
@Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME); builder.startObject(fieldName); builder.field(FROM_FIELD.getPreferredName(), maybeConvertToString(this.from)); builder.field(TO_FIELD.getPreferredName(), maybeConvertToString(this.to)); builder.field(INCLUDE_LOWER_FIELD.getPreferredName(), includeLower); builder.field(INCLUDE_UPPER_FIELD.getPreferredName(), includeUpper); if (timeZone != null) { builder.field(TIME_ZONE_FIELD.getPreferredName(), timeZone.getID()); } if (format != null) { builder.field(FORMAT_FIELD.getPreferredName(), format.format()); } if (relation != null) { builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName()); } printBoostAndQueryName(builder); builder.endObject(); builder.endObject(); }
@Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME); builder.startObject(fieldName); builder.field(FROM_FIELD.getPreferredName(), convertToStringIfBytesRef(this.from)); builder.field(TO_FIELD.getPreferredName(), convertToStringIfBytesRef(this.to)); builder.field(INCLUDE_LOWER_FIELD.getPreferredName(), includeLower); builder.field(INCLUDE_UPPER_FIELD.getPreferredName(), includeUpper); if (timeZone != null) { builder.field(TIME_ZONE_FIELD.getPreferredName(), timeZone.getID()); } if (format != null) { builder.field(FORMAT_FIELD.getPreferredName(), format.format()); } if (relation != null) { builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName()); } printBoostAndQueryName(builder); builder.endObject(); builder.endObject(); }
@Override protected void doXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(NAME); builder.startObject(fieldName); builder.field(FROM_FIELD.getPreferredName(), maybeConvertToString(this.from)); builder.field(TO_FIELD.getPreferredName(), maybeConvertToString(this.to)); builder.field(INCLUDE_LOWER_FIELD.getPreferredName(), includeLower); builder.field(INCLUDE_UPPER_FIELD.getPreferredName(), includeUpper); if (timeZone != null) { builder.field(TIME_ZONE_FIELD.getPreferredName(), timeZone.getID()); } if (format != null) { builder.field(FORMAT_FIELD.getPreferredName(), format.format()); } if (relation != null) { builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName()); } printBoostAndQueryName(builder); builder.endObject(); builder.endObject(); }
builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName());
builder.field(RELATION_FIELD.getPreferredName(), relation.getRelationName());
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(this.fieldName); out.writeGenericValue(this.from); out.writeGenericValue(this.to); out.writeBoolean(this.includeLower); out.writeBoolean(this.includeUpper); out.writeOptionalTimeZone(timeZone); String formatString = null; if (this.format != null) { formatString = this.format.format(); } out.writeOptionalString(formatString); if (out.getVersion().onOrAfter(Version.V_5_2_0)) { String relationString = null; if (this.relation != null) { relationString = this.relation.getRelationName(); } out.writeOptionalString(relationString); } }
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(this.fieldName); out.writeGenericValue(this.from); out.writeGenericValue(this.to); out.writeBoolean(this.includeLower); out.writeBoolean(this.includeUpper); out.writeOptionalTimeZone(timeZone); String formatString = null; if (this.format != null) { formatString = this.format.format(); } out.writeOptionalString(formatString); if (out.getVersion().onOrAfter(Version.V_5_2_0)) { String relationString = null; if (this.relation != null) { relationString = this.relation.getRelationName(); } out.writeOptionalString(relationString); } }
@Override protected void doWriteTo(StreamOutput out) throws IOException { out.writeString(this.fieldName); out.writeGenericValue(this.from); out.writeGenericValue(this.to); out.writeBoolean(this.includeLower); out.writeBoolean(this.includeUpper); out.writeOptionalTimeZone(timeZone); String formatString = null; if (this.format != null) { formatString = this.format.format(); } out.writeOptionalString(formatString); if (out.getVersion().onOrAfter(Version.V_5_2_0)) { String relationString = null; if (this.relation != null) { relationString = this.relation.getRelationName(); } out.writeOptionalString(relationString); } }