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
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
,Rewriteable<SortBuilder<?>>
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
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from class org.elasticsearch.search.sort.SortBuilder
NESTED_FILTER_FIELD, NESTED_PATH_FIELD, order, ORDER_FIELD
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
ConstructorDescriptionGeoDistanceSortBuilder(String fieldName, double lat, double lon)
Constructs a new distance based sort on a geo point like field.GeoDistanceSortBuilder(String fieldName, String... geohashes)
Constructs a new distance based sort on a geo point like field.GeoDistanceSortBuilder(String fieldName, GeoPoint... points)
Constructs a new distance based sort on a geo point like field.Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionbuild(SearchExecutionContext context)
Create a SortFieldAndFormat from this builder.buildBucketedSort(SearchExecutionContext context, BigArrays bigArrays, int bucketSize, BucketedSort.ExtraData extra)
Create a BucketedSort which is useful for sorting inside of aggregations.boolean
Returns the geo point like field the distance based sort operates on.static GeoDistanceSortBuilder
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser, String elementName)
Returns the geo distance type used to compute the distance.geoDistance(GeoDistance geoDistance)
The geo distance type used to compute the distance.Deprecated.Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)
and retrieve withgetNestedSort()
Returns theNestedSortBuilder
Returns the name of the writeable objectint
hashCode()
boolean
Returns true if unmapped geo fields should be treated as located at an infinite distanceignoreUnmapped(boolean ignoreUnmapped)
point(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.The point to create the range distance facets from.Rewrites this instance based on the provided context.setNestedFilter(QueryBuilder nestedFilter)
Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)
and retrieve withgetNestedSort()
setNestedPath(String nestedPath)
Deprecated.set nested sort withsetNestedSort(NestedSortBuilder)
and retrieve withgetNestedSort()
setNestedSort(NestedSortBuilder nestedSort)
Sets theNestedSortBuilder
to be used for fields that are inside a nested object.sortMode()
Returns which distance to use for sorting in the case a document contains multiple geo points.Defines which distance to use for sorting in the case a document contains multiple geo points.org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
unit()
Returns the distance unit to use.unit(DistanceUnit unit)
The distance unit to use.Returns the validation method to use for this sort builder.validation(GeoValidationMethod method)
Sets validation method for this sort builder.void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class org.elasticsearch.search.sort.SortBuilder
buildSort, fromXContent, order, order, parseNestedFilter, resolveNested, resolveNested, toString
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 Details
-
NAME
- See Also:
- Constant Field Values
-
ALTERNATIVE_NAME
- See Also:
- Constant Field Values
-
DEFAULT_VALIDATION
-
-
Constructor Details
-
GeoDistanceSortBuilder
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
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
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
Read from a stream.- Throws:
IOException
-
-
Method Details
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Throws:
IOException
-
fieldName
Returns the geo point like field the distance based sort operates on. -
point
The point to create the range distance facets from.- Parameters:
lat
- latitude.lon
- longitude.
-
points
The point to create the range distance facets from.- Parameters:
points
- reference points.
-
points
Returns the points to create the range distance facets from. -
geoDistance
The geo distance type used to compute the distance. -
geoDistance
Returns the geo distance type used to compute the distance. -
unit
The distance unit to use. Defaults toDistanceUnit.METERS
-
unit
Returns the distance unit to use. Defaults toDistanceUnit.METERS
-
validation
Sets validation method for this sort builder. -
validation
Returns the validation method to use for this sort builder. -
sortMode
Defines which distance to use for sorting in the case a document contains multiple geo points. Possible values: min and max -
sortMode
Returns which distance to use for sorting in the case a document contains multiple geo points. -
setNestedFilter
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.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.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.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
Returns theNestedSortBuilder
-
setNestedSort
Sets theNestedSortBuilder
to be used for fields that are inside a nested object. TheNestedSortBuilder
takes 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
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Throws:
IOException
-
getWriteableName
Description copied from interface:NamedWriteable
Returns the name of the writeable object -
equals
-
hashCode
public int hashCode() -
fromXContent
public static GeoDistanceSortBuilder fromXContent(org.elasticsearch.common.xcontent.XContentParser parser, String elementName) throws 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:
IOException
-
build
Description copied from class:SortBuilder
Create a SortFieldAndFormat from this builder.- Specified by:
build
in classSortBuilder<GeoDistanceSortBuilder>
- Throws:
IOException
-
buildBucketedSort
public BucketedSort buildBucketedSort(SearchExecutionContext context, BigArrays bigArrays, int bucketSize, BucketedSort.ExtraData extra) throws IOExceptionDescription copied from class:SortBuilder
Create a BucketedSort which is useful for sorting inside of aggregations.- Specified by:
buildBucketedSort
in classSortBuilder<GeoDistanceSortBuilder>
- Throws:
IOException
-
rewrite
Description copied from interface:Rewriteable
Rewrites 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:
IOException
-
setNestedSort(NestedSortBuilder)
and retrieve withgetNestedSort()