newDistanceSort

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.

x

x at the center.

y

y at the center.

Throws

if field is null or location has invalid coordinates.