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 Joshua O'Madadhain <jm...@ics.uci.edu> on 2001/11/14 01:13:59 UTC

compiling example code

I am attempting to build the example code which is located in the 

\lucene-1.2-rc2\src\demo\org\apache\lucene

directory in the distribution.  Specifically, I'm trying to get
IndexFiles.java, SearchFiles.java, and FileDocument.java to compile, as a
sanity check, before trying to go any further.  (The project is to develop
an extension to the vector model using fuzzy clustering; details available
if anyone wants them.)

Two of these files compile without error.  However, when I attempt to
compile IndexFiles.java, I get the following error:

C:\lucene-1.2-rc2\src\demo\org\apache\lucene\IndexFiles.java:95: cannot
resolve symbol
symbol  : variable FileDocument  
location: class org.apache.lucene.IndexFiles
      writer.addDocument(FileDocument.Document(file));
                         ^
1 error


I don't understand why I'm getting this error; FileDocument has already
been compiled, and the class is in the same directory as the other
documents.  Perhaps I'm just missing something basic about using packages,
but it all seems plausible.

Has anyone managed to get these examples to build, and if so, how?

Thanks--

Joshua

 jmadden@ics.uci.edu...Obscurium Per Obscurius...www.ics.uci.edu/~jmadden
    Joshua Madden: Information Scientist, Musician, Philosopher-At-Tall
 It's that moment of dawning comprehension that I live for--Bill Watterson
My opinions are too rational and insightful to be those of any organization.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: RAMdirectory from Directory ?

Posted by Winton Davies <wd...@overture.com>.
Many thanks Gerhard!

  Winton

Winton Davies
Lead Engineer, Overture (NSDQ: OVER)
1820 Gateway Drive, Suite 360
San Mateo, CA 94404
work: (650) 403-2259
cell: (650) 867-1598
http://www.overture.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: RAMdirectory from Directory ?

Posted by Winton Davies <wd...@overture.com>.
Hi again (sorry for the volume of question!)

I implemented this, with one change (the IndexWriter has to have TRUE 
set at the end, as ramdiris a new directory).

It loaded into memory, but then when I tried a search I got this stack trace:

java.lang.ArrayIndexOutOfBoundsException
         at java.lang.System.arraycopy(Native Method)
         at org.apache.lucene.store.RAMInputStream.readInternal(Unknown Source)
         at org.apache.lucene.store.InputStream.readBytes(Unknown Source)
         at org.apache.lucene.index.SegmentReader.norms(Unknown Source)
         at org.apache.lucene.index.SegmentReader.norms(Unknown Source)
         at org.apache.lucene.search.TermQuery.scorer(Unknown Source)
         at org.apache.lucene.search.Query.scorer(Unknown Source)
         at org.apache.lucene.search.IndexSearcher.search(Unknown Source)
         at org.apache.lucene.search.Hits.getMoreDocs(Unknown Source)
         at org.apache.lucene.search.Hits.<init>(Unknown Source)
         at org.apache.lucene.search.Searcher.search(Unknown Source)
         at org.apache.lucene.search.Searcher.search(Unknown Source)
         at 
com.go2.idxsearch.godzilla.MiniSearchListings.processOneQueryStringArr 
ay(MiniSearchListings.java:175)
         at 
com.go2.idxsearch.godzilla.FastGodzilla.callSearchResult(FastGodzilla. 
java:55)
         at 
com.go2.idxsearch.godzilla.FastGodzilla.setSortType(FastGodzilla.java: 
199)

Anyone have any ideas why it could fail ?

  Cheers,
    Winton


>Winton Davies wrote:
>>   I've an index that should fit in RAM -- but I need it stored as a
>> file. Is there anyway to read in the regular directory in the the
>> RAMDirectory and then create an IndexSearcher from this ? It seems
>> that there should be, but I can't find a method to construct a
>> RAMDirectory from a regular Directory ?
>
>Look at IndexWriter.addIndexes( Directory[] dirs )
>
>You can store your RAMDirectory into a new FSDirectory and load a
>FSDircetory into a new RAMDirectory.
>
>Something like:
>
>Directory loadIndex() {
>	Directory fs = FSDirectory.getDirectory( pathToIndex, false );
>	RAMDirectory ramdir = new RAMDircetory();
>	IndexWriter iw = new IndexWriter( ramdir, myAnalyzer, false );
>	iw.addIndexes( new Directory[]{fs} );
>	iw.close();
>	fs.close();
>	return ramdir;
>}
>void storeIndex( Directory ramdir ) {
>	Directory fs = FSDirectory.getDirectory( pathToIndex, true ); // create
>a new Index here
>	IndexWriter iw = new IndexWriter( fs, myAnalyzer, true );
>	iw.addIndexes( new Directory[]{ramdir} );
>	iw.close();
>	fs.close();
>}
>
>
>HTH,
>Gerhard
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


Winton Davies
Lead Engineer, Overture (NSDQ: OVER)
1820 Gateway Drive, Suite 360
San Mateo, CA 94404
work: (650) 403-2259
cell: (650) 867-1598
http://www.overture.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: RAMdirectory from Directory ?

Posted by Gerhard Schwarz <ge...@fpg.de>.
Winton Davies wrote:
>   I've an index that should fit in RAM -- but I need it stored as a
> file. Is there anyway to read in the regular directory in the the
> RAMDirectory and then create an IndexSearcher from this ? It seems
> that there should be, but I can't find a method to construct a
> RAMDirectory from a regular Directory ?

Look at IndexWriter.addIndexes( Directory[] dirs )

You can store your RAMDirectory into a new FSDirectory and load a
FSDircetory into a new RAMDirectory.

Something like: 

Directory loadIndex() {
	Directory fs = FSDirectory.getDirectory( pathToIndex, false );
	RAMDirectory ramdir = new RAMDircetory();
	IndexWriter iw = new IndexWriter( ramdir, myAnalyzer, false );
	iw.addIndexes( new Directory[]{fs} );
	iw.close();
	fs.close();
	return ramdir;
}
void storeIndex( Directory ramdir ) {
	Directory fs = FSDirectory.getDirectory( pathToIndex, true ); // create
a new Index here
	IndexWriter iw = new IndexWriter( fs, myAnalyzer, true );
	iw.addIndexes( new Directory[]{ramdir} );
	iw.close();
	fs.close();
}


HTH,
Gerhard

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RAMdirectory from Directory ?

Posted by Winton Davies <wd...@overture.com>.
Hi,
 
  I've an index that should fit in RAM -- but I need it stored as a 
file. Is there anyway to read in the regular directory in the the 
RAMDirectory and then create an IndexSearcher from this ? It seems 
that there should be, but I can't find a method to construct a 
RAMDirectory from a regular Directory ?

Cheers,
  Winton

Winton Davies
Lead Engineer, Overture (NSDQ: OVER)
1820 Gateway Drive, Suite 360
San Mateo, CA 94404
work: (650) 403-2259
cell: (650) 867-1598
http://www.overture.com/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: compiling example code

Posted by "Steven J. Owens" <pu...@darksleep.com>.
> On Tue, 13 Nov 2001, Alex Murzaku wrote:
> > Are you using ant? By just using "ant demo" from the lucene root
> > directory everything goes fine. Make sure you have the latest ant
> > (1.4).
> 
> I have no idea what ant is or what it's supposed to be for; I'll do a web
> search to see if I can get one (an idea, that is), but a brief explanation
> would be appreciated.  However, I would hope that it shouldn't be
> necessary to use a separate tool (aside from javac, that is) in order to
> just build some fairly basic sample code.

     Try reading http://www.darksleep.com/puff/lucene/lucenereadmedraft.txt

     You may also find http://www.darksleep.com/puff/lucene/lucene.html 
useful.  Please let me know if you have any problems at all with either
document, and I'll try to clarify them (and factor that clarification
back into the document).

Steven J. Owens
puff@darksleep.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: compiling example code

Posted by Joshua O'Madadhain <jm...@ics.uci.edu>.
On Tue, 13 Nov 2001, Alex Murzaku wrote:

> Are you using ant? By just using "ant demo" from the lucene root
> directory everything goes fine. Make sure you have the latest ant
> (1.4).

I have no idea what ant is or what it's supposed to be for; I'll do a web
search to see if I can get one (an idea, that is), but a brief explanation
would be appreciated.  However, I would hope that it shouldn't be
necessary to use a separate tool (aside from javac, that is) in order to
just build some fairly basic sample code.
 
> And also, I would be very interested in seeing what you are doing. At
> my previous job, we started building a clusterizer around lucene but
> turned out to be a little bit slow, so, we ended up building our own
> similarity measuring (manhattan distance between word vectors).

The basic idea is that I'm investigating a technique that combines fuzzy
term expansion and fuzzy reranking of query results: the term expansion
should help improve recall, and the reranking should help to improve
precision.  You do this by creating a weighted graph that represents word
similarities in some fashion and adding to the query those terms that are
sufficiently close to the query terms (using your favorite definitions of
"sufficient" and "close").  On the back end, you include in the ranking
of each document a factor that takes account of just how fuzzy a match the
terms in the document are for the query terms.

How fast this will be, especially for this prototype, I don't know; right
now I'm more interested in its effect on recall and precision than
anything else.  It does require some additional overhead up front (when
the index is created) but shouldn't require too much extra work on a
query-by-query basis.  We shall see.  :)

Joshua

 jmadden@ics.uci.edu...Obscurium Per Obscurius...www.ics.uci.edu/~jmadden
    Joshua Madden: Information Scientist, Musician, Philosopher-At-Tall
 It's that moment of dawning comprehension that I live for--Bill Watterson
My opinions are too rational and insightful to be those of any organization.

> Two of these files compile without error.  However, when I attempt to
> compile IndexFiles.java, I get the following error:
> 
> C:\lucene-1.2-rc2\src\demo\org\apache\lucene\IndexFiles.java:95: cannot
> resolve symbol
> symbol  : variable FileDocument
> location: class org.apache.lucene.IndexFiles
>       writer.addDocument(FileDocument.Document(file));
>                          ^
> 1 error
> 
> 
> I don't understand why I'm getting this error; FileDocument has already
> been compiled, and the class is in the same directory as the other
> documents.  Perhaps I'm just missing something basic about using packages,
> but it all seems plausible.
> 
> Has anyone managed to get these examples to build, and if so, how?


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: compiling example code

Posted by Alex Murzaku <mu...@earthlink.net>.
Are you using ant? By just using "ant demo" from the lucene root directory
everything goes fine. Make sure you have the latest ant (1.4).

And also, I would be very interested in seeing what you are doing. At my
previous job, we started building a clusterizer around lucene but turned out
to be a little bit slow, so, we ended up building our own similarity
measuring (manhattan distance between word vectors).

Alex

-----Original Message-----
From: Joshua O'Madadhain [mailto:jmadden@ics.uci.edu]
Sent: Tuesday, November 13, 2001 7:14 PM
To: lucene-user@jakarta.apache.org
Subject: compiling example code


I am attempting to build the example code which is located in the

\lucene-1.2-rc2\src\demo\org\apache\lucene

directory in the distribution.  Specifically, I'm trying to get
IndexFiles.java, SearchFiles.java, and FileDocument.java to compile, as a
sanity check, before trying to go any further.  (The project is to develop
an extension to the vector model using fuzzy clustering; details available
if anyone wants them.)

Two of these files compile without error.  However, when I attempt to
compile IndexFiles.java, I get the following error:

C:\lucene-1.2-rc2\src\demo\org\apache\lucene\IndexFiles.java:95: cannot
resolve symbol
symbol  : variable FileDocument
location: class org.apache.lucene.IndexFiles
      writer.addDocument(FileDocument.Document(file));
                         ^
1 error


I don't understand why I'm getting this error; FileDocument has already
been compiled, and the class is in the same directory as the other
documents.  Perhaps I'm just missing something basic about using packages,
but it all seems plausible.

Has anyone managed to get these examples to build, and if so, how?

Thanks--

Joshua

 jmadden@ics.uci.edu...Obscurium Per Obscurius...www.ics.uci.edu/~jmadden
    Joshua Madden: Information Scientist, Musician, Philosopher-At-Tall
 It's that moment of dawning comprehension that I live for--Bill Watterson
My opinions are too rational and insightful to be those of any organization.


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>