For single field sorting I am using this code
searchSourceBuilder.sort(SortBuilders.fieldSort("count").order(SortOrder.DESC));
but now I need to add condition like this
searchSourceBuilder.sort(SortBuilders.fieldSort(count <= 0 ? "visitor":"visitor" * "count").order(SortOrder.DESC));
I am not getting any clue to do this. Is it possible at elasticsearch or I need to do it another way?