lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Josh Guice" <>
Subject FW: Manually creating a RAMDirectory from pre-existing index files.
Date Fri, 05 Apr 2002 19:09:11 GMT
**Apologies for sending this to wrong list (for those of you on both), I
entered the mail archive from the rear-end and didn't realize there was
a user list as well as a developer list...again...sorry :)

-----Original Message-----
From: Josh Guice [] 
Sent: Friday, April 05, 2002 1:01 PM
To: ''
Subject: Manually creating a RAMDirectory from pre-existing index files.

(Using version 1.2rc4 of canned Lucene)

I am working on a document navigation/browsing applet and want to
implement a client-side search that is completely independent of any
server mechanism, yet is still fast (i.e. not a "crawler").  It will be
LAN-based, so moving large files is not an issue.

Currently I create an index of the files to be searched in the
traditional Lucene manner and store them on a web server.  From the
applet I open each of these pre-existing files and do a byte->byte copy
to a RAMDirectory (RD) in the client applet's memory.  I am then able to
access the files from the RD in the applet, list their sizes (which
match up with the originals) and read back their contents (which also
match up with the origs, byte-for-byte).  However, when I attempt to
create an IndexSearcher by passing my RAMDirectory, I get the following

Error creating IndexSearcher!

java.lang.ArrayIndexOutOfBoundsException: 116 >= 7
	at java.util.Vector.elementAt(Unknown Source)
	at org.apache.lucene.index.FieldInfos.fieldInfo(Unknown Source)
	at org.apache.lucene.index.FieldInfos.fieldName(Unknown Source)
	at org.apache.lucene.index.SegmentTermEnum.readTerm(Unknown
	at Source)
	at org.apache.lucene.index.TermInfosReader.readIndex(Unknown
	at org.apache.lucene.index.TermInfosReader.<init>(Unknown
	at org.apache.lucene.index.SegmentReader.<init>(Unknown Source)
	at org.apache.lucene.index.SegmentReader.<init>(Unknown Source)
	at org.apache.lucene.index.IndexReader$1.doBody(Unknown Source)
	at$ Source)
	at Source)
	at<init>(Unknown Source)
	at Search.finishedLoad(

I can successfully pass the physical index directory to an IndexReader
and everything is fine, so I know the index files are ok.  Here is the
code I use to get and copy each file to the client applets memory:

	public void addItem(String dataLine) // dataLine is the real
filename      							// of an
index component
		// Get file
			InputStreamReader fileIn; outFile;
			URL url; 
			URLConnection urlConn; 
			int EOF;
			// Process file
			url = new URL(
				+ "index/" + dataLine); 
			urlConn = url.openConnection();
			fileIn = new
			System.out.println("File: " + dataLine + 
							   ", Length: "
+ urlConn.getContentLength());
			// indices is a pre-defined RAMDirectory
			outFile = indices.createFile(dataLine);
			EOF =;
			while (EOF != -1)
				EOF =;
		catch (MalformedURLException mue)
			System.out.println("!!Error Bad data file link "
			_applet.getCodeBase().toString() + "/" +
		catch (IOException ioe)
			System.out.println("!!Error Reading " + 
			_applet.getCodeBase().toString() + "/" +

And here is the code I use to create the IndexSearcher:


			searcher = new IndexSearcher(indices);
		catch (Exception ioe)
			System.out.println("Error creating

This is when the exception gets thrown...

Any ideas on why this wouldn't be working?


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message