Stratio / cassandra-lucene-index

Lucene based secondary indexes for Cassandra
Apache License 2.0
600 stars 170 forks source link

The last row positions in "IndexPagingState" may be deleted when querying the next page. #388

Open johnyannj opened 6 years ago

johnyannj commented 6 years ago

SCLI's IndexPagingState contains the last row positions, which is used to query next page. (com.stratio.cassandra.lucene.IndexPagingState)

But the row may be deleted when querying the next page.

In com.stratio.cassandra.lucene.index.DocumentIterator we will get an Exception with "Last page position not found".

Is it possible to record scoreDocs directly into the IndexPagingState ?

DocumentIterator.scala:

 private[this] val afters = try {
    indices.map(i => afterTerms(i).map(term => {
      val time = TimeCounter.start
      val builder = new BooleanQuery.Builder
      builder.add(new TermQuery(term), FILTER)
      builder.add(query, MUST)
      val scores = searchers(i).search(builder.build, 1, sort).scoreDocs
      if (scores.nonEmpty) {
        tracer.trace("Lucene index seeks last index position")
        logger.debug(s"Start position found in $time")
        scores.head
      } else throw new IndexException("Last page position not found")
    })).toArray
  } catch {
    case e: Exception =>
      releaseSearchers()
      throw new IndexException(e, "Error while searching for the last page position")
  }