简体   繁体   English

将我的代码移植到NEST 2.0和ElasticSearch 2.0

[英]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. 我正在将.NET C#WebAPI的端口从NEST 1.0移植到最新的NEST 2.0。 Elasticsearch has been updated to 2.0 as well. Elasticsearch也已更新至2.0。

.Filters() has been replaced with .Query() which is fine. .Filters()已替换为.Query() ,这很好。

However, I can't find the equivalent for .SortAscending() . 但是,我找不到.SortAscending()的等效.SortAscending() There is a .Sort() but how can I specify the order? 有一个.Sort()但如何指定顺序? (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. Intellisense显示我应该通过一个IPromise类型的selector ,这在某种程度上很有用,但是一个简单的示例会更好。 Anyway, really can't understand by intellisense alone... 无论如何,真的不能仅凭智能感知就无法理解...

Here is the example. 这是例子。

For asc: 对于asc:

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

For desc: 对于desc:

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

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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