Gianluca Ghettini
Gianluca Ghettini

Reputation: 11628

porting my code to NEST 2.0 and ElasticSearch 2.0

I'm doing a port of my .NET C# WebAPI from NEST 1.0 to the newest NEST 2.0. Elasticsearch has been updated to 2.0 as well.

.Filters() has been replaced with .Query() which is fine.

However, I can't find the equivalent for .SortAscending(). There is a .Sort() but how can I specify the order? (ascending, descending)

Intellisense shows I should pass a selector of type IPromise which is useful is some way but a plain example would be much better. Anyway, really can't understand by intellisense alone...

Upvotes: 0

Views: 373

Answers (1)

Rob
Rob

Reputation: 9979

Here is the example.

For asc:

var searchResults = client.Search<Document>(s => s
    .Query(q => q.MatchAll())
    .Sort(sort => sort.Ascending(f => f.Name)));

For desc:

var searchResults = client.Search<Document>(s => s
    .Query(q => q.MatchAll())
    .Sort(sort => sort.Descending(f => f.Name)));

Hope it helps.

Upvotes: 1

Related Questions