Skip to content

[FEATURE] Support GeoDistanceSort #6800

Closed
@michael-budnik

Description

@michael-budnik

Elastic.Clients.Elasticsearch version: 8.0.0-beta.6

Description of the problem including expected versus actual behavior:
I'm migrating (well, trying) one of our smallest APIs to 8.x.
In one of our calls we're sorting on distance from a point.
I've managed to get to this

.Sort(new[] { new SortCombinations(
      SortOptions.GeoDistance(new GeoDistanceSort
          {
              Field = (Expression<Func<MyClass, object>>)(x => x.Address.Coordinates),
              Order = SortOrder.Asc,
              Location = new List<GeoLocation>() {new GeoLocation() /* esPostcode.Lat, esPostcode.Long */ },
              DistanceType = GeoDistanceType.Arc
          }))
  }));

As you can see there a few problems with it.

  1. Field should probably just be a generic expression of TDocument. I've noticed this issue in other places as well.
  2. Can't provide coords. GeoLocation is an empty class.
    SortCombinations should probably be singular as constructor accepts only single SortOption.

Expected behavior
Should be able to specify lat lon.
Should be able to specify field expression easier.

Also question going forward.
I could easily add several more tickets like this but not sure what are the expectations for this 'beta phase'.
What kind of stuff do you expect to be reported at this stage?

Metadata

Metadata

Assignees

No one assigned

    Labels

    8.xRelates to a 8.x client version

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions