Skip to content

No implicit conversion from ScoreSort to SortOptions #8702

@MEmanuelsson

Description

@MEmanuelsson

Elastic.Clients.Elasticsearch version:
8.19.6

Elasticsearch version:
8.17.1

.NET runtime version:
9.0.9

Operating system version:
Windows

Description of the problem including expected versus actual behavior:
I'm not sure if this is a bug or if we're doing something wrong but when trying to upgrade from version 8.18.3 to 8.19.6 we're having problem with one final piece of code connected to ScoreSort and SortOptions.

The code we're trying to upgrade looks like this in 8.18.3:

var sortOptions = new List<SortOptions>();
sortOptions.Add(SortOptions.GeoDistance(new GeoDistanceSort
{
    Field = "fieldname",
    Location = [GeoLocation.LatitudeLongitude(new LatLonGeoLocation { Lat = 1.1, Lon = 2.2 })],
    Order = SortOrder.Asc,
    Unit = DistanceUnit.Meters,
    Mode = SortMode.Min
}));
sortOptions.Add(SortOptions.Score(new ScoreSort()));

In 8.19.6 we have this so far but the piece of code we're not sure about how to migrate is connected to the addition of ScoreSort to the list:

var sortOptions = new List<SortOptions>();
sortOptions.Add(new GeoDistanceSort
{
    Field = "fieldname",
    Location = [GeoLocation.LatitudeLongitude(new LatLonGeoLocation { Lat = 1.1, Lon = 2.2 })],
    Order = SortOrder.Asc,
    Unit = DistanceUnit.Meters,
    Mode = SortMode.Min
});
sortOptions.Add(new ScoreSort()); //<-- Does not build

What's the right way to add ScoreSort to the list of SortOptions? Or is this perhaps not necessary, maybe this is added implicitly by Elasticsearch?

Steps to reproduce:

  1. Add code above to solution using 8.18.3
  2. Upgrade to 8.19.6
  3. Code does not build

Expected behavior
Would expect to be able to add ScoreSort like it was possible to do in 8.18.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions