How to get most recent documents in .NET NEST 2.xx?


(David) #1

I have the code below but it does not sort the most recent documents.

            var r = client.Search<Topic>(s => s
                .From(from)
                .Size(size)
                .MatchAll()
                .Sort(ss => ss.Descending(p=>p.Datetime))
             );

Remark : my field is well mapped to "Date" type in the class :

[ElasticsearchType(Name = "Topic")]
public class Topic
{
    [Date()]
    public DateTime Datetime { get; set; } 

    [String(Index = FieldIndexOption.NotAnalyzed)]
    public string Description { get; set; }

}

Any idea please ?
Thanks.


(system) #2