lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Toke Eskildsen ...@statsbiblioteket.dk>
Subject Re: Score 0
Date Thu, 26 Jun 2008 09:37:07 GMT
On Wed, 2008-06-25 at 21:47 +0200, Paolo Valleri wrote: 
> For take docid of all document in the index I need to write a class
> that implement indexReader or there is an other method ?

Something along the following should work and be quite fast. However, it
might be overly complex.

  // Do this every time the index is updated
  IndexReader reader = IndexReader.open(indexLocation);
  BitSet deleted = new BitSet(reader.maxDoc());
  for (int i = 0 ; i < reader.maxDoc() ; i++) {
      if (reader.isDeleted(i)) {
          deleted.set(i);
      }
  }
  QueryParser parser =
          new QueryParser("freetext", new StandardAnalyzer());

  // Do this for every search
  Query query = parser.parse("java");
  QueryWrapperFilter filter = new QueryWrapperFilter(query);
  BitSet workset = filter.bits(reader);
  workset.or(deleted);
  // workset now marks all docids that are either matching or deleted
  System.out.print("Non-matching documents: ");
  for (int i = 0 ; i < reader.maxDoc() ; i++) {
       if (!workset.get(i)) {
          System.out.print(i + " ");
      }
  }



---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message