nest - ElasticSearch Order By String

Question: How do you order by Date in Elasticsearch Nest C# API.

Answer: See the code below

var  response = await _elasticClient.SearchAsync<MyIndex>
                             (
                      s => s.Query(q => q.QueryString(d => d.Query("Technology")))
                      .Sort(a => a.Descending(b => b.DateInserted))
                          .From((page - 1) * pageSize)
                          .Size(pageSize));

 


Edit this Article
ElasticSearch Nest C-Sharp .NET 6 published
Was this page helpful?
Yes Yes! this solution to the problem was helpful. No No! this solution to the problem was not helpful.. Leave ErnesTech Feedback.Feedback
If you log in, you will be notified when someone leaves a comment.

Other users would like to know if this solution helped you.

Your Session is Ending
Login to Continue

© 2021 - ErnesTech - Privacy