lucene-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lucenewbie <>
Subject Extreme Beginner Needs Lucene Help
Date Thu, 29 Sep 2011 07:31:41 GMT
I'm trying to write a Lucene program to index a large .txt file. 

Really, it should be extremely basic, I just want to learn how to use Lucene
but I'm getting all sorts of strange errors when I try simple lines of code. 

Here's an example: 

		StandardAnalyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
		boolean recreateIndexIfExists = true;
		IndexWriter indexWriter = new IndexWriter("/indexDirectory", analyzer,

>From what I read in the documentation and the official Lucene Book, there
should be nothing wrong with that. The error I get most often is "the
IndexWriter(String, StandardAnalyzer, boolean) constructor is not defined.

So I'm going to guess the problem lies elsewhere. 

Here's a confession: I've never used any external jars when writing java
programs before. Nor have I ever needed to edit my Path or Classpath
variables. So I'm going to run through a list of things I've done to try to
"connect" Lucene, hopefully they'll weed out any suggestions you might have.
But first:

-I am using Eclipse though I tried to run the program
downloaded from manning's site in Textpad and the problem persisted, with
the same flavor of error. 
-I am on a Windows OS
-I am using java version 1.7
-Lucene version 3.4.0

Here are the things I've done so far:

1) Added the Lucene core and lucene demo jars to my system classpath. (While
I'm reasonably certain I did this correctly, I'm at the point where I just
feel like I've made a really stupid mistake and don't want to leave anything
out, so here is what my CLASSPATH looks like now):

.;C:\Program Files

(unrelated question: I'm using java 1.7 in my PATH variable. I don't know
why that reference to jre6 is still there but I didn't want to remove it.
The same folder in jre7 doesn't contain so I figured it couldn't
be harmful. Anyone know what I should do there?)

2) (Somewhat related to the unrelated question:) I added both of the .jars
to the \lib\ext folders of both the jre6 folder referenced in my path and
the jre7 folder that presumably should be. I read somewhere this is
essentially the same as adding to the CLASSPATH and I did so when I was
having trouble figuring out just wtf I was doing (which I still am).

3) I configured the Build Path for my java project to include all relevant
jars (the core and demo jars as well as their javadoc jars)

4) I have import statements out the wazoo. I mention this because it took me
a while to figure out that I needed them because the book doesn't include
them nor does it even mention their existence. Remember, this is my first
time working with external code like this. I'm sure I seem fully retarded
but I guess I thought that referencing the jars gave me everything I needed
out of the box. 

5) I found this
website  and copied and pasted the code to see if it would work and it works
flawlessly. It's simply not useful because it creates the index in memory,
manually adds documents, and prints results. Since my biggest problem right
now is the index directory and referencing the file to be indexed, that
flawless program just doesn't help me. 

So I'm really just at a loss. I've found several other websites with some
sample "getting started" programs but they all give me various amounts of
similarly confusing errors. 

site  was particularly useful as it had pics of what my project should look
like in Eclipse. 

Thank you for any help you can offer. I'm sorry if it hurts your head to see
something as stupid as this. I promise my head is hurting right now, too. 

Oh and lastly, since I don't seem to have any shame, here's another probably
newbish question:

When Eclipse tells me that something is 'deprecated' (e.g. The Field
Version.LUCENE_CURRENT is deprecated), what does that mean? It's just a
warning and Eclipse suggests that I just Suppress Deprecation Warnings as a
quick fix but I'd rather know what's up. Some of the sample code I tested
had a StandardAnalyzer with nothing being passed and those gave me errors. I
had to add the Version.LUCENE_CURRENT to fix them. Additionally, the java
documentation for Lucene is riddled with deprecation this and deprecation
that. If I had to guess, I would say it's like doing something a quick and
dirty way that's kind of frowned upon. 

Thanks again

View this message in context:
Sent from the Lucene - General mailing list archive at

View raw message