lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin <cry...@yahoo.com>
Subject Infinite loop when searching empty index
Date Fri, 26 Feb 2010 21:54:22 GMT
Is this a bug in Lucene Java as of trunk@915399?

    int numDocs = reader.numDocs(); // = 0 (empty index)
    TopDocsCollector collector = TopScoreDocCollector.create(numDocs, 
true);
    searcher.search(new MatchAllDocsQuery(), collector);  // never 
returns

    // Searcher
    public void search(Query query, Collector collector)
      throws IOException {
      search(createWeight(query), null, collector); // never returns
    }

    // extends IndexSearcher
    public void search(Weight weight, Filter filter, final Collector collector) throws IOException
{
      boolean topScorer = (filter == null) true : false;
      Scorer scorer = weight.scorer(reader, true, topScorer);
      if (scorer != null && topScorer) {
        scorer.score(collector); // never returns

    // Scorer
    public void score(Collector collector) throws IOException {
      collector.setScorer(this);
      int doc;
      while ((doc = nextDoc()) != NO_MORE_DOCS) { // doc = 0 (infinite)
        collector.collect(doc);
      }
    }


Thanks for any feedback,
Justin


      

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