java.lang.IllegalArgumentException: nDocs must be > 0

mediawiki.org | 6 days ago
  1. 0

    Extension talk:Lucene-search/archive/2009 - MediaWiki

    mediawiki.org | 6 days ago
    java.lang.IllegalArgumentException: nDocs must be > 0
  2. 0

    As I was trying out dimensional fields for SOLR-8396, I realized that DimensionalRangeQuery is not working with UninvertingReader. In Solr, all directory readers are wrapped by an UninvertingReader and an ExitableDirectoryReader. Here's the error: {code} Exception in thread "main" java.lang.IllegalArgumentException: field="rating" was indexed with numDims=0 but this query has numDims=1 at org.apache.lucene.search.DimensionalRangeQuery$1.scorer(DimensionalRangeQuery.java:186) at org.apache.lucene.search.Weight.bulkScorer(Weight.java:135) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:667) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:474) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:593) at org.apache.lucene.search.IndexSearcher.searchAfter(IndexSearcher.java:451) at org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:462) at DimensionalRangeQueryExample.query(DimensionalRangeQueryExample.java:66) {code} Here's an example program to trigger this failure: {code} import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Random; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.DimensionalIntField; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import org.apache.lucene.document.Field.Store; import org.apache.lucene.document.LegacyIntField; import org.apache.lucene.document.StringField; import org.apache.lucene.document.TextField; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexWriter; import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.StoredDocument; import org.apache.lucene.queryparser.classic.ParseException; import org.apache.lucene.search.DimensionalRangeQuery; import org.apache.lucene.search.IndexSearcher; import org.apache.lucene.search.LegacyNumericRangeQuery; import org.apache.lucene.search.Query; import org.apache.lucene.search.ScoreDoc; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; import org.apache.lucene.store.RAMDirectory; import org.apache.lucene.uninverting.UninvertingReader; import org.apache.lucene.util.BytesRef; public class DimensionalRangeQueryExample { public static void main(String[] args) throws IOException, ParseException { StandardAnalyzer analyzer = new StandardAnalyzer(); Directory index = new RAMDirectory(); IndexWriterConfig config = new IndexWriterConfig(analyzer); IndexWriter w = new IndexWriter(index, config); addDoc(w, "Lucene in Action", 1); addDoc(w, "Lucene for Dummies", 2); addDoc(w, "Managing Gigabytes", 3); addDoc(w, "The Art of Computer Science", 4); w.commit(); w.close(); DirectoryReader reader = (DirectoryReader.open(index)); Map<String, UninvertingReader.Type> uninvertingMap = new HashMap<>(); uninvertingMap.put("id", UninvertingReader.Type.BINARY); uninvertingMap.put("rating", UninvertingReader.Type.INTEGER); reader = UninvertingReader.wrap(reader, uninvertingMap); IndexSearcher searcher = new IndexSearcher(reader); Query legacyQuery = LegacyNumericRangeQuery.newIntRange("rating_legacy", 1, 4, true, true); Query dimensionalQuery = DimensionalRangeQuery.new1DIntRange("rating", 1, true, 4, true); System.out.println("Legacy query: "); query(legacyQuery, searcher); // works System.out.println("Dimensional query: "); query(dimensionalQuery, searcher); // fails reader.close(); } private static void query(Query q, IndexSearcher searcher) throws IOException { int hitsPerPage = 10; TopDocs docs = searcher.search(q, hitsPerPage); ScoreDoc[] hits = docs.scoreDocs; System.out.println("Found " + hits.length + " hits."); for(int i=0;i<hits.length;++i) { int docId = hits[i].doc; StoredDocument d = searcher.doc(docId); System.out.println((i + 1) + ". " + d); } } private static void addDoc(IndexWriter w, String title, int rating) throws IOException { Document doc = new Document(); String id = ""+new Random().nextInt(1000); byte idBytes[] = id.getBytes(); doc.add(new StringField("id", new BytesRef(idBytes), Store.YES)); doc.add(new TextField("title", title, Field.Store.YES)); doc.add(new DimensionalIntField("rating", rating)); LegacyIntField legacy = new LegacyIntField("rating_legacy", rating, Store.YES); legacy.setIntValue(rating); doc.add(legacy); w.addDocument(doc); } } {code} I don't yet know more as to why this could be. [~mikemccand] Any ideas, please? Apologies if I should've brought this up in the mailing lists, or as a comment in LUCENE-6917 itself.

    Apache's JIRA Issue Tracker | 11 months ago | Ishan Chattopadhyaya
    java.lang.IllegalArgumentException: field="rating" was indexed with numDims=0 but this query has numDims=1
  3. 0

    GitHub comment 71#55646437

    GitHub | 2 years ago | halpimded
    java.lang.IllegalArgumentException: y must be >= 0
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Formatter fails with IllegalArgumentException "length must be >= 0"

    Eclipse Bugzilla | 1 year ago | jesper.eskilson
    java.lang.IllegalArgumentException: length must be >= 0
  6. 0

    Categorize error for negative approx_percentile weight

    GitHub | 10 months ago | electrum
    java.lang.IllegalArgumentException: count must be > 0

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.IllegalArgumentException

      nDocs must be > 0

      at org.apache.lucene.search.IndexSearcher.search()
    2. Lucene
      IndexSearcher.search
      1. org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:110)
      1 frame
    3. org.wikimedia.lsearch
      WikiSearcher.search
      1. org.wikimedia.lsearch.search.WikiSearcher.search(WikiSearcher.java:184)
      1 frame
    4. Lucene
      Searcher.search
      1. org.apache.lucene.search.Searcher.search(Searcher.java:132)
      1 frame
    5. org.wikimedia.lsearch
      HttpHandler.run
      1. org.wikimedia.lsearch.search.SearchEngine.search(SearchEngine.java:722)
      2. org.wikimedia.lsearch.search.SearchEngine.search(SearchEngine.java:129)
      3. org.wikimedia.lsearch.frontend.SearchDaemon.processRequest(SearchDaemon.java:101)
      4. org.wikimedia.lsearch.frontend.HttpHandler.handle(HttpHandler.java:193)
      5. org.wikimedia.lsearch.frontend.HttpHandler.run(HttpHandler.java:114)
      5 frames
    6. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
      3. java.lang.Thread.run(Thread.java:637)
      3 frames