Package org.opensearch.index.query
Class GeoDistanceQueryBuilder
java.lang.Object
org.opensearch.index.query.AbstractQueryBuilder<GeoDistanceQueryBuilder>
org.opensearch.index.query.GeoDistanceQueryBuilder
- All Implemented Interfaces:
org.opensearch.core.common.io.stream.NamedWriteable
,org.opensearch.core.common.io.stream.Writeable
,org.opensearch.core.xcontent.ToXContent
,org.opensearch.core.xcontent.ToXContentObject
,QueryBuilder
,Rewriteable<QueryBuilder>
,WithFieldName
public class GeoDistanceQueryBuilder
extends AbstractQueryBuilder<GeoDistanceQueryBuilder>
implements WithFieldName
Filter results of a query to include only those within a specific distance to some
geo point.
- Opensearch.internal:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.opensearch.core.xcontent.ToXContent
org.opensearch.core.xcontent.ToXContent.DelegatingMapParams, org.opensearch.core.xcontent.ToXContent.MapParams, org.opensearch.core.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.opensearch.core.common.io.stream.Writeable
org.opensearch.core.common.io.stream.Writeable.Reader<V>, org.opensearch.core.common.io.stream.Writeable.WriteableRegistry, org.opensearch.core.common.io.stream.Writeable.Writer<V>
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DistanceUnit
Default for distance unit computation.static final GeoDistance
Default for geo distance computation.static final boolean
The default value for ignore_unmapped.static final String
Fields inherited from class org.opensearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
Fields inherited from interface org.opensearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
Fields inherited from interface org.opensearch.core.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorsConstructorDescriptionGeoDistanceQueryBuilder
(String fieldName) Construct new GeoDistanceQueryBuilder.GeoDistanceQueryBuilder
(org.opensearch.core.common.io.stream.StreamInput in) Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptiondouble
distance()
Returns the distance configured as radius.distance
(double distance, DistanceUnit unit) Sets the distance from the center for this query.Sets the distance from the center using the default distance unit.distance
(String distance, DistanceUnit unit) Sets the distance from the center for this query.protected boolean
doEquals
(GeoDistanceQueryBuilder other) Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.protected int
protected org.apache.lucene.search.Query
doToQuery
(QueryShardContext shardContext) protected void
doWriteTo
(org.opensearch.core.common.io.stream.StreamOutput out) protected void
doXContent
(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) Name of the field this query is operating on.static GeoDistanceQueryBuilder
fromXContent
(org.opensearch.core.xcontent.XContentParser parser) Returns geo distance calculation type to use.geoDistance
(GeoDistance geoDistance) Which type of geo distance calculation method to use.Sets the center point for this query.Returns validation method for geo coordinates.boolean
Gets whether the query builder will ignore unmapped fields (and run aMatchNoDocsQuery
in place of this query) or throw an exception if the field is unmapped.ignoreUnmapped
(boolean ignoreUnmapped) Sets whether the query builder should ignore unmapped fields (and run aMatchNoDocsQuery
in place of this query) or throw an exception if the field is unmapped.point()
Returns the center point of the distance query.point
(double lat, double lon) Sets the center point of the query.Sets the center point for the query.void
Set validation method for geo coordinates.Methods inherited from class org.opensearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, doRewrite, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toQuery, toString, toXContent, writeTo
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.opensearch.index.query.QueryBuilder
visit
Methods inherited from interface org.opensearch.core.xcontent.ToXContentObject
isFragment
-
Field Details
-
NAME
- See Also:
-
DEFAULT_DISTANCE_UNIT
Default for distance unit computation. -
DEFAULT_GEO_DISTANCE
Default for geo distance computation. -
DEFAULT_IGNORE_UNMAPPED
public static final boolean DEFAULT_IGNORE_UNMAPPEDThe default value for ignore_unmapped.- See Also:
-
-
Constructor Details
-
GeoDistanceQueryBuilder
Construct new GeoDistanceQueryBuilder.- Parameters:
fieldName
- name of indexed geo field to operate distance computation on.
-
GeoDistanceQueryBuilder
public GeoDistanceQueryBuilder(org.opensearch.core.common.io.stream.StreamInput in) throws IOException Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteTo
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
- Throws:
IOException
-
fieldName
Name of the field this query is operating on.- Specified by:
fieldName
in interfaceWithFieldName
-
point
Sets the center point for the query.- Parameters:
point
- the center of the query
-
point
Sets the center point of the query.- Parameters:
lat
- latitude of centerlon
- longitude of center
-
point
Returns the center point of the distance query. -
distance
Sets the distance from the center using the default distance unit. -
distance
Sets the distance from the center for this query. -
distance
Sets the distance from the center for this query. -
distance
public double distance()Returns the distance configured as radius. -
geohash
Sets the center point for this query. -
geoDistance
Which type of geo distance calculation method to use. -
geoDistance
Returns geo distance calculation type to use. -
setValidationMethod
Set validation method for geo coordinates. -
getValidationMethod
Returns validation method for geo coordinates. -
ignoreUnmapped
Sets whether the query builder should ignore unmapped fields (and run aMatchNoDocsQuery
in place of this query) or throw an exception if the field is unmapped. -
ignoreUnmapped
public boolean ignoreUnmapped()Gets whether the query builder will ignore unmapped fields (and run aMatchNoDocsQuery
in place of this query) or throw an exception if the field is unmapped. -
doToQuery
protected org.apache.lucene.search.Query doToQuery(QueryShardContext shardContext) throws IOException - Specified by:
doToQuery
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
- Throws:
IOException
-
doXContent
protected void doXContent(org.opensearch.core.xcontent.XContentBuilder builder, org.opensearch.core.xcontent.ToXContent.Params params) throws IOException - Specified by:
doXContent
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
- Throws:
IOException
-
fromXContent
public static GeoDistanceQueryBuilder fromXContent(org.opensearch.core.xcontent.XContentParser parser) throws IOException - Throws:
IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCode
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilder
Indicates whether some otherQueryBuilder
object of the same type is "equal to" this one.- Specified by:
doEquals
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
-
getWriteableName
- Specified by:
getWriteableName
in interfaceorg.opensearch.core.common.io.stream.NamedWriteable
-