Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-556

MatchAllDocsQuery, MultiSearcher and a custom HitCollector throwing exception

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 2.0.0
    • Component/s: core/search
    • Labels:
      None
    • Environment:

      xp sp2, jdk1.5

      Description

      I have encountered an issue with lucene1.9.1. It involves MatchAllDocsQuery, MultiSearcher and a custom HitCollector. The following code throws java.lang.UnsupportedOperationException.

      If I remove the MatchAllDocsQuery condition (comment whole //1 block), or if I dont use the custom hitcollector (ms.search(mbq); instead of ms.search(mbq, allcoll) the exception goes away. By stepping into the source I can see it seems due to MatchAllDocsQuery no implementing extractTerms()....

      Searcher searcher = new
      IndexSearcher("c:\\projects\\mig\\runtime\\index\\01Aug16
      ");
      Searchable[] indexes = new IndexSearcher[1];
      indexes[0] = searcher;
      MultiSearcher ms = new MultiSearcher(indexes);

      AllCollector allcoll = new AllCollector(ms);

      BooleanQuery mbq = new BooleanQuery();
      mbq.add(new TermQuery(new Term("body", "value1")),
      BooleanClause.Occur.MUST_NOT);
      // 1
      MatchAllDocsQuery alld = new MatchAllDocsQuery();
      mbq.add(alld, BooleanClause.Occur.MUST);
      //

      System.out.println("Query: " + mbq.toString());

      // 2
      ms.search(mbq, allcoll);
      //ms.search(mbq);

        Activity

        Hide
        yseeley@gmail.com Yonik Seeley added a comment -

        Fixed. Added empty implementation for MatchAllDocsQuery and ConstantScoreQuery.

        Show
        yseeley@gmail.com Yonik Seeley added a comment - Fixed. Added empty implementation for MatchAllDocsQuery and ConstantScoreQuery.
        Hide
        jmwap jmwap added a comment -

        I used a custom version and my queries work now, but I am not sure wether this is ok...it's mostly an easy shot I took:

        public class LuceneMatchAllDocsCustomQuery extends MatchAllDocsQuery {
        public void extractTerms(Set terms) {
        }
        }

        Show
        jmwap jmwap added a comment - I used a custom version and my queries work now, but I am not sure wether this is ok...it's mostly an easy shot I took: public class LuceneMatchAllDocsCustomQuery extends MatchAllDocsQuery { public void extractTerms(Set terms) { } }

          People

          • Assignee:
            yseeley@gmail.com Yonik Seeley
            Reporter:
            jmwap jmwap
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development