Reputation: 5871
I am trying to sort list of Person by their first name. using Open Declaration org.springframework.data.domain.Sort.Order.Order.ignoreCase()
as shown below.
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.data.domain.Sort.Order;
Order sortOrfer = new Order(Sort.Direction.ASC, "firstName").ignoreCase();
In ES repository, I have person name with different cases. for example.
I am expecting the sorted data as shown below.
But the data is sorted as below, which is not correct(not expected),
the root cause of this behavior is that for ajai
first letter is in small case. According to ES cases insensitive sorting is supported, Can any one tell me how can I fix this?
Upvotes: 1
Views: 1824
Reputation: 405
The package you are calling is part of core spring data, not ES specific. Elasticsearch must be setup with the proper mapping, and indexed with those settings. As far as I know, Elasticsearch has no such ability in Query DSL to sort the way you're asking (alphabetical vs lexicographical). If you are trying to sort on the client-side, that would only sort the results returned for the first page, probably not what you are intending.
Also see this post which worked for us.
Upvotes: 1