简体   繁体   中英

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...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM