public class GeoDistanceQueryBuilder extends AbstractQueryBuilder<GeoDistanceQueryBuilder>
Writeable.Reader<V>, Writeable.Writer<V>
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.Params
Modifier and Type | Field and 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 boolean |
DEFAULT_NORMALIZE_LAT
Default for latitude normalization (as of this writing true).
|
static boolean |
DEFAULT_NORMALIZE_LON
Default for longitude normalization (as of this writing true).
|
static java.lang.String |
DEFAULT_OPTIMIZE_BBOX
Deprecated.
|
static java.lang.String |
NAME |
boost, BOOST_FIELD, DEFAULT_BOOST, NAME_FIELD, queryName
EMPTY_PARAMS
Constructor and Description |
---|
GeoDistanceQueryBuilder(StreamInput in)
Read from a stream.
|
GeoDistanceQueryBuilder(java.lang.String fieldName)
Construct new GeoDistanceQueryBuilder.
|
Modifier and Type | Method and 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 other
QueryBuilder 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 java.util.Optional<GeoDistanceQueryBuilder> |
fromXContent(QueryParseContext parseContext) |
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 object
|
boolean |
ignoreUnmapped()
Gets whether the query builder will ignore unmapped fields (and run a
MatchNoDocsQuery 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 a
MatchNoDocsQuery in place of this query) or throw an exception if
the field is unmapped. |
java.lang.String |
optimizeBbox()
Deprecated.
|
GeoDistanceQueryBuilder |
optimizeBbox(java.lang.String optimizeBbox)
Deprecated.
|
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.
|
addValidationError, boost, boost, convertToBytesRefIfString, convertToStringIfBytesRef, declareStandardFields, doRewrite, equals, extractInnerHitBuilders, getName, hashCode, printBoostAndQueryName, queryName, queryName, readQueries, requireValue, rewrite, throwParsingExceptionOnMultipleFields, toFilter, toQueries, toQuery, toXContent, writeQueries, writeTo
buildAsBytes, buildAsBytes, toString, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
rewriteQuery
public static final java.lang.String NAME
public static final boolean DEFAULT_NORMALIZE_LAT
public static final boolean DEFAULT_NORMALIZE_LON
public static final DistanceUnit DEFAULT_DISTANCE_UNIT
public static final GeoDistance DEFAULT_GEO_DISTANCE
@Deprecated public static final java.lang.String DEFAULT_OPTIMIZE_BBOX
public static final boolean DEFAULT_IGNORE_UNMAPPED
public GeoDistanceQueryBuilder(java.lang.String fieldName)
fieldName
- name of indexed geo field to operate distance computation on.public GeoDistanceQueryBuilder(StreamInput in) throws java.io.IOException
java.io.IOException
protected void doWriteTo(StreamOutput out) throws java.io.IOException
doWriteTo
in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
java.io.IOException
public java.lang.String fieldName()
public GeoDistanceQueryBuilder point(GeoPoint point)
point
- the center of the querypublic GeoDistanceQueryBuilder point(double lat, double lon)
lat
- latitude of centerlon
- longitude of centerpublic GeoPoint point()
public GeoDistanceQueryBuilder distance(java.lang.String distance)
public GeoDistanceQueryBuilder distance(java.lang.String distance, DistanceUnit unit)
public GeoDistanceQueryBuilder distance(double distance, DistanceUnit unit)
public double distance()
public GeoDistanceQueryBuilder geohash(java.lang.String geohash)
public GeoDistanceQueryBuilder geoDistance(GeoDistance geoDistance)
public GeoDistance geoDistance()
@Deprecated public GeoDistanceQueryBuilder optimizeBbox(java.lang.String optimizeBbox)
@Deprecated public java.lang.String optimizeBbox()
public void setValidationMethod(GeoValidationMethod method)
public GeoValidationMethod getValidationMethod()
public GeoDistanceQueryBuilder ignoreUnmapped(boolean ignoreUnmapped)
MatchNoDocsQuery
in place of this query) or throw an exception if
the field is unmapped.public boolean ignoreUnmapped()
MatchNoDocsQuery
in place of this query) or throw an exception if
the field is unmapped.protected org.apache.lucene.search.Query doToQuery(QueryShardContext shardContext) throws java.io.IOException
doToQuery
in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
java.io.IOException
protected void doXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
doXContent
in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
java.io.IOException
public static java.util.Optional<GeoDistanceQueryBuilder> fromXContent(QueryParseContext parseContext) throws java.io.IOException
java.io.IOException
protected int doHashCode()
doHashCode
in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
protected boolean doEquals(GeoDistanceQueryBuilder other)
AbstractQueryBuilder
QueryBuilder
object of the same type is "equal to" this one.doEquals
in class AbstractQueryBuilder<GeoDistanceQueryBuilder>
public java.lang.String getWriteableName()
NamedWriteable