Hi, I search for an query. Total searched records are 5000. I only shows 100 records on one page. So I passed 100 as nDocs.
I write the code in this way. IndexSearcher searcher = new IndexSearcher(FSDirectory.open(new File(path))); Query query = new QueryParser(Version.LUCENE_30, "field1", new StandardAnalyzer(Version.LUCENE_30)).parse("query"); Query query1 = new QueryParser(Version.LUCENE_30, "field2", new StandardAnalyzer(Version.LUCENE_30)).parse("query2"); BooleanQuery lucBoolQueryOTHER = new BooleanQuery(); lucBoolQueryOTHER.add(query, Occur.MUST); lucBoolQueryOTHER.add(query1, Occur.MUST); TopDocs hits=searcher.search(query, null, 100); System.err.println("Total searched " + hits.totalHits); >> 5000 System.err.println("Total docs " + hits.scoreDocs.length); >> 100 // The code to print 100 records on first page for(int i=0;i<hits.scoreDocs.length;i++){ System.out.println(searcher.doc(hits.scoreDocs[i].doc).getField("filename")); } it worked fine. // Now I want to show all next search documents on Second Pages...when I tried in this way, I got the error. for(int i=100;i<hits.totalHits;i++){ System.out.println(searcher.doc(hits.scoreDocs[i].doc).getField("filename")); } searcher.close(); java.lang.ArrayIndexOutOfBoundsException: 100 at Test.searchIndex(Test.java:96) at Test.main(Test.java:54) Would need to perform searching again with different parameters to fetch next bunch of records ? Thanks