i am having an accounts index in elastic search
i want to sort it based on a particular coloumn and get results
i want to display data in chunks like 10 at a time.
so i wrote the following query :
SearchResponse sr = (ts.prepareSearch("acc").addSort(sort_param.toLowerCase(), SortOrder.ASC).setSize(size).searchAfter(lastHit).execute().actionGet());
first sorting and them set size and then search from the last hit user got.
for example : the user is searching base don account number then he will get the first 10 records and next he will get from 11thh record.
_> now my problem is when i am using it based on like gender i am getting first 10 records of female now when i am searching for next then i am getting the next 10 records of MALE _
> but i should be getting next 10 female records or whatever based on the results of the query.
its giving weird results for the non continuous sets of values like age, account numbers etc..
like for age its given results of first 10 recs with age 20 and next page with 22. even if there are results with age 20 more than 10, its truncating those.