newDistanceSort

fun newDistanceSort(field: String, latitude: Double, longitude: Double): SortField

Creates a SortField for sorting by distance from a location.

This sort orders documents by ascending distance from the location. The value returned in FieldDoc for the hits contains a Double instance with the distance in meters.

If a document is missing the field, then by default it is treated as having distance (missing values sort last).

If a document contains multiple values for the field, the closest distance to the location is used.

Return

SortField ordering documents by distance

Parameters

field

field name. must not be null.

latitude

latitude at the center: must be within standard +/-90 coordinate bounds.

longitude

longitude at the center: must be within standard +/-180 coordinate bounds.

Throws

if field is null or location has invalid coordinates.