Package org.elasticsearch.index.query
Class GeoDistanceQueryBuilder
- java.lang.Object
-
- org.elasticsearch.index.query.AbstractQueryBuilder<GeoDistanceQueryBuilder>
-
- org.elasticsearch.index.query.GeoDistanceQueryBuilder
-
- All Implemented Interfaces:
NamedWriteable
,Writeable
,ToXContent
,ToXContentObject
,QueryBuilder
,Rewriteable<QueryBuilder>
public class GeoDistanceQueryBuilder extends AbstractQueryBuilder<GeoDistanceQueryBuilder>
Filter results of a query to include only those within a specific distance to some geo point.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
-
Field Summary
Fields Modifier and Type Field Description static DistanceUnit
DEFAULT_DISTANCE_UNIT
Default for distance unit computation.static GeoDistance
DEFAULT_GEO_DISTANCE
Default for geo distance computation.static boolean
DEFAULT_IGNORE_UNMAPPED
The default value for ignore_unmapped.static java.lang.String
NAME
-
Fields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
-
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description GeoDistanceQueryBuilder(java.lang.String fieldName)
Construct new GeoDistanceQueryBuilder.GeoDistanceQueryBuilder(StreamInput in)
Read from a stream.
-
Method Summary
Modifier and Type Method Description double
distance()
Returns the distance configured as radius.GeoDistanceQueryBuilder
distance(double distance, DistanceUnit unit)
Sets the distance from the center for this query.GeoDistanceQueryBuilder
distance(java.lang.String distance)
Sets the distance from the center using the default distance unit.GeoDistanceQueryBuilder
distance(java.lang.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
doHashCode()
protected org.apache.lucene.search.Query
doToQuery(QueryShardContext shardContext)
protected void
doWriteTo(StreamOutput out)
protected void
doXContent(XContentBuilder builder, ToXContent.Params params)
java.lang.String
fieldName()
Name of the field this query is operating on.static GeoDistanceQueryBuilder
fromXContent(XContentParser parser)
GeoDistance
geoDistance()
Returns geo distance calculation type to use.GeoDistanceQueryBuilder
geoDistance(GeoDistance geoDistance)
Which type of geo distance calculation method to use.GeoDistanceQueryBuilder
geohash(java.lang.String geohash)
Sets the center point for this query.GeoValidationMethod
getValidationMethod()
Returns validation method for geo coordinates.java.lang.String
getWriteableName()
Returns the name of the writeable objectboolean
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.GeoDistanceQueryBuilder
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.GeoPoint
point()
Returns the center point of the distance query.GeoDistanceQueryBuilder
point(double lat, double lon)
Sets the center point of the query.GeoDistanceQueryBuilder
point(GeoPoint point)
Sets the center point for the query.void
setValidationMethod(GeoValidationMethod method)
Set validation method for geo coordinates.-
Methods inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
addValidationError, boost, boost, checkNegativeBoost, declareStandardFields, doRewrite, equals, extractInnerHitBuilders, getName, hashCode, parseInnerQueryBuilder, printBoostAndQueryName, queryName, queryName, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toFilter, toQuery, toString, toString, toXContent, writeTo
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentObject
isFragment
-
-
-
-
Field Detail
-
NAME
public static final java.lang.String NAME
- See Also:
- Constant Field Values
-
DEFAULT_DISTANCE_UNIT
public static final DistanceUnit DEFAULT_DISTANCE_UNIT
Default for distance unit computation.
-
DEFAULT_GEO_DISTANCE
public static final GeoDistance DEFAULT_GEO_DISTANCE
Default for geo distance computation.
-
DEFAULT_IGNORE_UNMAPPED
public static final boolean DEFAULT_IGNORE_UNMAPPED
The default value for ignore_unmapped.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GeoDistanceQueryBuilder
public GeoDistanceQueryBuilder(java.lang.String fieldName)
Construct new GeoDistanceQueryBuilder.- Parameters:
fieldName
- name of indexed geo field to operate distance computation on.
-
GeoDistanceQueryBuilder
public GeoDistanceQueryBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
doWriteTo
protected void doWriteTo(StreamOutput out) throws java.io.IOException
- Specified by:
doWriteTo
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()
Name of the field this query is operating on.
-
point
public GeoDistanceQueryBuilder point(GeoPoint point)
Sets the center point for the query.- Parameters:
point
- the center of the query
-
point
public GeoDistanceQueryBuilder point(double lat, double lon)
Sets the center point of the query.- Parameters:
lat
- latitude of centerlon
- longitude of center
-
point
public GeoPoint point()
Returns the center point of the distance query.
-
distance
public GeoDistanceQueryBuilder distance(java.lang.String distance)
Sets the distance from the center using the default distance unit.
-
distance
public GeoDistanceQueryBuilder distance(java.lang.String distance, DistanceUnit unit)
Sets the distance from the center for this query.
-
distance
public GeoDistanceQueryBuilder distance(double distance, DistanceUnit unit)
Sets the distance from the center for this query.
-
distance
public double distance()
Returns the distance configured as radius.
-
geohash
public GeoDistanceQueryBuilder geohash(java.lang.String geohash)
Sets the center point for this query.
-
geoDistance
public GeoDistanceQueryBuilder geoDistance(GeoDistance geoDistance)
Which type of geo distance calculation method to use.
-
geoDistance
public GeoDistance geoDistance()
Returns geo distance calculation type to use.
-
setValidationMethod
public void setValidationMethod(GeoValidationMethod method)
Set validation method for geo coordinates.
-
getValidationMethod
public GeoValidationMethod getValidationMethod()
Returns validation method for geo coordinates.
-
ignoreUnmapped
public GeoDistanceQueryBuilder 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.
-
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 java.io.IOException
- Specified by:
doToQuery
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
- Throws:
java.io.IOException
-
doXContent
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
doXContent
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
- Throws:
java.io.IOException
-
fromXContent
public static GeoDistanceQueryBuilder fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()
- Specified by:
doHashCode
in classAbstractQueryBuilder<GeoDistanceQueryBuilder>
-
doEquals
protected boolean doEquals(GeoDistanceQueryBuilder other)
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
public java.lang.String getWriteableName()
Description copied from interface:NamedWriteable
Returns the name of the writeable object
-
-