Package org.elasticsearch.search.sort
Class GeoDistanceSortBuilder
- java.lang.Object
-
- org.elasticsearch.search.sort.SortBuilder<GeoDistanceSortBuilder>
-
- org.elasticsearch.search.sort.GeoDistanceSortBuilder
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentObject,Rewriteable<SortBuilder<?>>
public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
A geo distance based sorting on a geo point like field.
-
-
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 java.lang.StringALTERNATIVE_NAMEstatic GeoValidationMethodDEFAULT_VALIDATIONstatic java.lang.StringNAME-
Fields inherited from interface org.elasticsearch.index.query.Rewriteable
MAX_REWRITE_ROUNDS
-
Fields inherited from class org.elasticsearch.search.sort.SortBuilder
NESTED_FILTER_FIELD, NESTED_PATH_FIELD, order, ORDER_FIELD
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Constructor Description GeoDistanceSortBuilder(java.lang.String fieldName, double lat, double lon)Constructs a new distance based sort on a geo point like field.GeoDistanceSortBuilder(java.lang.String fieldName, java.lang.String... geohashes)Constructs a new distance based sort on a geo point like field.GeoDistanceSortBuilder(java.lang.String fieldName, GeoPoint... points)Constructs a new distance based sort on a geo point like field.GeoDistanceSortBuilder(StreamInput in)Read from a stream.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description SortFieldAndFormatbuild(QueryShardContext context)Create a @linkSortFieldAndFormatfrom this builder.booleanequals(java.lang.Object object)java.lang.StringfieldName()Returns the geo point like field the distance based sort operates on.static GeoDistanceSortBuilderfromXContent(XContentParser parser, java.lang.String elementName)GeoDistancegeoDistance()Returns the geo distance type used to compute the distance.GeoDistanceSortBuildergeoDistance(GeoDistance geoDistance)The geo distance type used to compute the distance.GeoDistanceSortBuildergeohashes(java.lang.String... geohashes)Deprecated.QueryBuildergetNestedFilter()Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()java.lang.StringgetNestedPath()Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()NestedSortBuildergetNestedSort()Returns theNestedSortBuilderjava.lang.StringgetWriteableName()Returns the name of the writeable objectinthashCode()booleanignoreUnmapped()Returns true if unmapped geo fields should be treated as located at an infinite distanceGeoDistanceSortBuilderignoreUnmapped(boolean ignoreUnmapped)GeoDistanceSortBuilderpoint(double lat, double lon)The point to create the range distance facets from.GeoPoint[]points()Returns the points to create the range distance facets from.GeoDistanceSortBuilderpoints(GeoPoint... points)The point to create the range distance facets from.GeoDistanceSortBuilderrewrite(QueryRewriteContext ctx)Rewrites this instance based on the provided context.GeoDistanceSortBuildersetNestedFilter(QueryBuilder nestedFilter)Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()GeoDistanceSortBuildersetNestedPath(java.lang.String nestedPath)Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()GeoDistanceSortBuildersetNestedSort(NestedSortBuilder nestedSort)Sets theNestedSortBuilderto be used for fields that are inside a nested object.SortModesortMode()Returns which distance to use for sorting in the case a document contains multiple geo points.GeoDistanceSortBuildersortMode(SortMode sortMode)Defines which distance to use for sorting in the case a document contains multiple geo points.XContentBuildertoXContent(XContentBuilder builder, ToXContent.Params params)DistanceUnitunit()Returns the distance unit to use.GeoDistanceSortBuilderunit(DistanceUnit unit)The distance unit to use.GeoValidationMethodvalidation()Returns the validation method to use for this sort builder.GeoDistanceSortBuildervalidation(GeoValidationMethod method)Sets validation method for this sort builder.voidwriteTo(StreamOutput out)Write this into the StreamOutput.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.index.query.Rewriteable
-
Methods inherited from class org.elasticsearch.search.sort.SortBuilder
buildSort, fromXContent, order, order, parseNestedFilter, resolveNested, resolveNested, toString
-
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
-
ALTERNATIVE_NAME
public static final java.lang.String ALTERNATIVE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_VALIDATION
public static final GeoValidationMethod DEFAULT_VALIDATION
-
-
Constructor Detail
-
GeoDistanceSortBuilder
public GeoDistanceSortBuilder(java.lang.String fieldName, GeoPoint... points)Constructs a new distance based sort on a geo point like field.- Parameters:
fieldName- The geo point like field name.points- The points to create the range distance facets from.
-
GeoDistanceSortBuilder
public GeoDistanceSortBuilder(java.lang.String fieldName, double lat, double lon)Constructs a new distance based sort on a geo point like field.- Parameters:
fieldName- The geo point like field name.lat- Latitude of the point to create the range distance facets from.lon- Longitude of the point to create the range distance facets from.
-
GeoDistanceSortBuilder
public GeoDistanceSortBuilder(java.lang.String fieldName, java.lang.String... geohashes)Constructs a new distance based sort on a geo point like field.- Parameters:
fieldName- The geo point like field name.geohashes- The points to create the range distance facets from.
-
GeoDistanceSortBuilder
public GeoDistanceSortBuilder(StreamInput in) throws java.io.IOException
Read from a stream.- Throws:
java.io.IOException
-
-
Method Detail
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:WriteableWrite this into the StreamOutput.- Throws:
java.io.IOException
-
fieldName
public java.lang.String fieldName()
Returns the geo point like field the distance based sort operates on.
-
point
public GeoDistanceSortBuilder point(double lat, double lon)
The point to create the range distance facets from.- Parameters:
lat- latitude.lon- longitude.
-
points
public GeoDistanceSortBuilder points(GeoPoint... points)
The point to create the range distance facets from.- Parameters:
points- reference points.
-
points
public GeoPoint[] points()
Returns the points to create the range distance facets from.
-
geohashes
@Deprecated public GeoDistanceSortBuilder geohashes(java.lang.String... geohashes)
Deprecated.The geohash of the geo point to create the range distance facets from. Deprecated - please use points(GeoPoint... points) instead.
-
geoDistance
public GeoDistanceSortBuilder geoDistance(GeoDistance geoDistance)
The geo distance type used to compute the distance.
-
geoDistance
public GeoDistance geoDistance()
Returns the geo distance type used to compute the distance.
-
unit
public GeoDistanceSortBuilder unit(DistanceUnit unit)
The distance unit to use. Defaults toDistanceUnit.METERS
-
unit
public DistanceUnit unit()
Returns the distance unit to use. Defaults toDistanceUnit.METERS
-
validation
public GeoDistanceSortBuilder validation(GeoValidationMethod method)
Sets validation method for this sort builder.
-
validation
public GeoValidationMethod validation()
Returns the validation method to use for this sort builder.
-
sortMode
public GeoDistanceSortBuilder sortMode(SortMode sortMode)
Defines which distance to use for sorting in the case a document contains multiple geo points. Possible values: min and max
-
sortMode
public SortMode sortMode()
Returns which distance to use for sorting in the case a document contains multiple geo points.
-
setNestedFilter
@Deprecated public GeoDistanceSortBuilder setNestedFilter(QueryBuilder nestedFilter)
Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()Sets the nested filter that the nested objects should match with in order to be taken into account for sorting.
-
getNestedFilter
@Deprecated public QueryBuilder getNestedFilter()
Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()Returns the nested filter that the nested objects should match with in order to be taken into account for sorting.
-
setNestedPath
@Deprecated public GeoDistanceSortBuilder setNestedPath(java.lang.String nestedPath)
Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()Sets the nested path if sorting occurs on a field that is inside a nested object. By default when sorting on a field inside a nested object, the nearest upper nested object is selected as nested path.
-
getNestedPath
@Deprecated public java.lang.String getNestedPath()
Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)and retrieve withgetNestedSort()Returns the nested path if sorting occurs on a field that is inside a nested object. By default when sorting on a field inside a nested object, the nearest upper nested object is selected as nested path.
-
getNestedSort
public NestedSortBuilder getNestedSort()
Returns theNestedSortBuilder
-
setNestedSort
public GeoDistanceSortBuilder setNestedSort(NestedSortBuilder nestedSort)
Sets theNestedSortBuilderto be used for fields that are inside a nested object. TheNestedSortBuildertakes a `path` argument and an optional nested filter that the nested objects should match with in order to be taken into account for sorting.
-
ignoreUnmapped
public boolean ignoreUnmapped()
Returns true if unmapped geo fields should be treated as located at an infinite distance
-
ignoreUnmapped
public GeoDistanceSortBuilder ignoreUnmapped(boolean ignoreUnmapped)
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Throws:
java.io.IOException
-
getWriteableName
public java.lang.String getWriteableName()
Description copied from interface:NamedWriteableReturns the name of the writeable object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
fromXContent
public static GeoDistanceSortBuilder fromXContent(XContentParser parser, java.lang.String elementName) throws java.io.IOException
- Parameters:
parser- the input parser. The state on the parser contained in this context will be changed as a side effect of this method callelementName- in some sort syntax variations the field name precedes the xContent object that specifies further parameters, e.g. in '{ "foo": { "order" : "asc"} }'. When parsing the inner object, the field name can be passed in via this argument- Throws:
java.io.IOException
-
build
public SortFieldAndFormat build(QueryShardContext context) throws java.io.IOException
Description copied from class:SortBuilderCreate a @linkSortFieldAndFormatfrom this builder.- Specified by:
buildin classSortBuilder<GeoDistanceSortBuilder>- Throws:
java.io.IOException
-
rewrite
public GeoDistanceSortBuilder rewrite(QueryRewriteContext ctx) throws java.io.IOException
Description copied from interface:RewriteableRewrites this instance based on the provided context. The returned objects will be the same instance as this if no changes during the rewrite were applied.- Throws:
java.io.IOException
-
-