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,org.elasticsearch.common.xcontent.ToXContent,org.elasticsearch.common.xcontent.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
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.ParamsNested 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 DistanceUnitDEFAULT_DISTANCE_UNITDefault for distance unit computation.static GeoDistanceDEFAULT_GEO_DISTANCEDefault for geo distance computation.static booleanDEFAULT_IGNORE_UNMAPPEDThe default value for ignore_unmapped.static java.lang.StringNAMEFields inherited from class org.elasticsearch.index.query.AbstractQueryBuilder
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName -
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 doubledistance()Returns the distance configured as radius.GeoDistanceQueryBuilderdistance(double distance, DistanceUnit unit)Sets the distance from the center for this query.GeoDistanceQueryBuilderdistance(java.lang.String distance)Sets the distance from the center using the default distance unit.GeoDistanceQueryBuilderdistance(java.lang.String distance, DistanceUnit unit)Sets the distance from the center for this query.protected booleandoEquals(GeoDistanceQueryBuilder other)Indicates whether some otherQueryBuilderobject of the same type is "equal to" this one.protected intdoHashCode()protected org.apache.lucene.search.QuerydoToQuery(QueryShardContext shardContext)protected voiddoWriteTo(StreamOutput out)protected voiddoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)java.lang.StringfieldName()Name of the field this query is operating on.static GeoDistanceQueryBuilderfromXContent(org.elasticsearch.common.xcontent.XContentParser parser)GeoDistancegeoDistance()Returns geo distance calculation type to use.GeoDistanceQueryBuildergeoDistance(GeoDistance geoDistance)Which type of geo distance calculation method to use.GeoDistanceQueryBuildergeohash(java.lang.String geohash)Sets the center point for this query.GeoValidationMethodgetValidationMethod()Returns validation method for geo coordinates.java.lang.StringgetWriteableName()Returns the name of the writeable objectbooleanignoreUnmapped()Gets whether the query builder will ignore unmapped fields (and run aMatchNoDocsQueryin place of this query) or throw an exception if the field is unmapped.GeoDistanceQueryBuilderignoreUnmapped(boolean ignoreUnmapped)Sets whether the query builder should ignore unmapped fields (and run aMatchNoDocsQueryin place of this query) or throw an exception if the field is unmapped.GeoPointpoint()Returns the center point of the distance query.GeoDistanceQueryBuilderpoint(double lat, double lon)Sets the center point of the query.GeoDistanceQueryBuilderpoint(GeoPoint point)Sets the center point for the query.voidsetValidationMethod(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, toQuery, toString, toXContent, writeTo
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
-
Constructor Details
-
GeoDistanceQueryBuilder
public GeoDistanceQueryBuilder(java.lang.String fieldName)Construct new GeoDistanceQueryBuilder.- Parameters:
fieldName- name of indexed geo field to operate distance computation on.
-
GeoDistanceQueryBuilder
Read from a stream.- Throws:
java.io.IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteToin classAbstractQueryBuilder<GeoDistanceQueryBuilder>- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()Name of the field this query is operating on. -
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 aMatchNoDocsQueryin 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 aMatchNoDocsQueryin 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:
doToQueryin classAbstractQueryBuilder<GeoDistanceQueryBuilder>- Throws:
java.io.IOException
-
doXContent
protected void doXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
doXContentin classAbstractQueryBuilder<GeoDistanceQueryBuilder>- Throws:
java.io.IOException
-
fromXContent
public static GeoDistanceQueryBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
doHashCode
protected int doHashCode()- Specified by:
doHashCodein classAbstractQueryBuilder<GeoDistanceQueryBuilder>
-
doEquals
Description copied from class:AbstractQueryBuilderIndicates whether some otherQueryBuilderobject of the same type is "equal to" this one.- Specified by:
doEqualsin classAbstractQueryBuilder<GeoDistanceQueryBuilder>
-
getWriteableName
public java.lang.String getWriteableName()Description copied from interface:NamedWriteableReturns the name of the writeable object
-