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

Gianluca Ghettini
  • 11,129
  • 19
  • 93
  • 159
  • 1
    take a look at GA release of nest 2.0 article (https://www.elastic.co/blog/ga-release-of-nest-2-0-our-dot-net-client-for-elasticsearch) - it has a sample of search ascending. Is this what you are looking for? – Alexander Feb 25 '16 at 10:26
  • @Alexander yes, this is what I was looking for albeit there's no real world example in there – Gianluca Ghettini Feb 25 '16 at 10:31

1 Answers1

1

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.

Rob
  • 9,664
  • 3
  • 41
  • 43
  • Thanks! works like a charm. How did you manage to find out how to do it? The documentation is still in development and there is just few pages describing the breaking changes from NEST 1.0 to 2.0. Did you had a look at the test code in the github repo? – Gianluca Ghettini Feb 25 '16 at 11:03
  • I saw issue regarding this some time ago on NEST [github](https://github.com/elastic/elasticsearch-net). You can go there and check if you will encounter any other problems, also I know guys are working really hard to release awesome documentation, so stay tuned :) – Rob Feb 25 '16 at 11:12
  • got a reply on twitter from the guys working on it. They are writing the doc – Gianluca Ghettini Feb 25 '16 at 11:28