Weird results using Search After () elastic search


(Ayshwarya Sree) #1
  1. i am having an accounts index in elastic search

  2. i want to sort it based on a particular coloumn and get results

  3. 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.


(Adrien Grand) #2

We recommend to include a unique field in the sort for that reason, so that documents never compare equal.


(Ayshwarya Sree) #3

Thanks for attention.
Here account number is a unique field..even with unique field there is no change as you can see..
Any other suggestions are appreciated. @jpountz i am still getting only first 10 records with age 20 when next is pressed all those remainnig are gone and age 21 records are being returned.


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.