lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivan cruces <ivan.cru...@object-matrix.com>
Subject Lucene pagination using searchAfter while index is updated
Date Fri, 17 Nov 2017 08:30:29 GMT
Hi,

I have implemented pagination with Lucene using the searchAfter method
provided by IndexSearcher. In every call, I pass the last ScoreDoc returned
in the previous page.

The problem is that sometimes, the index gets updated between page and page
and occasionally I am getting this exception:

java.lang.IllegalArgumentException: after.doc exceeds the number of
documents in the reader: after.doc=337 limit=337
    at
org.apache.lucene.search.IndexSearcher.searchAfter(IndexSearcher.java:434)

I understand that Lucene changes the docs ids every now and then (segment
merges, etc.) and I guess that is why that exception is happening as
searchAfter relies on those docs ids.

How could I improve this pagination mechanism to avoid this exception? Is
there any better way to implement pagination with Lucene?


Thanks,

Iván.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message