Home » Java » Sorting in ElasticSearch in java Fails-Exceptionshub

Sorting in ElasticSearch in java Fails-Exceptionshub

Posted by: admin February 25, 2020 Leave a comment

Questions:

Trying to sort results from elasticSearch, using elasticSearch-Rest-Client 6.8.3 in java, fails without any exception (it goes directly to the finally section).
In the following example, I cannot reach the line of sortB, as sortA fails and no exception is thrown.

try
{
    FieldSortBuilder sortA = new FieldSortBuilder("date").order(SortOrder.DESC);
    FieldSortBuilder sortB = new FieldSortBuilder("id").order(SortOrder.DESC);
}
catch (Exception ex)
{
  throw ex;
}
finally
{
  // Do Something
}
How to&Answers: