Skip to content

Sorting by multiple fields when creating a SortOptionsDescriptor<T> results in only the last field sorting #8471

@c5racing

Description

@c5racing

Elastic.Clients.Elasticsearch version: 8.1.7

.NET runtime version: .NET 9

Description of the problem including expected versus actual behavior:
I have a generic method and I pass in a SortOptionsDescriptor. When chaining multiple fields, sort is only occurring on the last field.

Steps to reproduce:

var defaultSort = new SortOptionsDescriptor<SearchWindowElasticSearchModel>().Field(a => a.Test, fs => fs.Order(SortOrder.Asc)).Field(a => a.Name, fs => fs.Order(SortOrder.Asc)).Field(a => a.SortOrder, fs => fs.Order(SortOrder.Asc)).Field(a => a.LastName, fs => fs.Order(SortOrder.Asc));

Expected behavior
I'd expect my search to be sorted by Test, Name, SortOrder, and then LastName.

What's occuring is my search is only sorting by LastName

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions