You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Guntupalli Shanti <sg...@cisco.com> on 2003/09/12 23:45:23 UTC

hits found ..couldn't retrieve documents

Hi All,

I have a strange problem...I have indexed a couple of Web pages (used 
htmlparser for HTML to text conversion)
and I can see the index created. When I search for a term, lucene returns 
the hits and score. But when I try to
retrieve the document (hits.doc(int)) it gives me the following error

"Exception in thread "main" java.io.IOException: The system cannot find the 
path specified"
at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(Unknown Source)
at org.apache.lucene.store.FSInputStream.readInternal(Unknown Source)
at org.apache.lucene.store.InputStream.refill(Unknown Source)
at org.apache.lucene.store.InputStream.readByte(Unknown Source)
at org.apache.lucene.store.InputStream.readInt(Unknown Source)
at org.apache.lucene.store.InputStream.readLong(Unknown Source)
at org.apache.lucene.index.FieldsReader.doc(Unknown Source)
at org.apache.lucene.index.SegmentReader.document(Unknown Source)
at org.apache.lucene.search.IndexSearcher.doc(Unknown Source)
at org.apache.lucene.search.Hits.doc(Unknown Source)
at WebPageSearcher.main(WebPageSearcher.java:86)

Here is sample code

indexing: (which works fine)

   public void index(String uid, String title, String text) {
     try {
       IndexWriter writer = new 
IndexWriter("d:\\tomcat\\webapps\\ROOT\\url_index", analyzer, true);
       Document document = new Document();
       document.add(Field.Keyword("uid", uid));
       document.add(Field.Text("title", title));
       document.add(Field.UnStored("pagebody", text));

       writer.addDocument(document);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }

Searching: (gives error on the line hits.doc(i))

..........
..........
       	searcher = new IndexSearcher("d:\\tomcat\\webapps\\ROOT\\url_index");
       	Query query = QueryParser.parse(queryString, "pagebody", new 
StandardAnalyzer());
       	hits = searcher.search(query);
           for (int i=0;i< hits.length();i++) {
          	    Document doc = hits.doc(i);
	    String doctitle = doc.get("title");
	    String url = doc.get("uid");
   	  }
   }

I appreciate your time and help
Thanks..Shanti