Looks like you're trying to write code using old Lucene syntax with the newest available jar.
Your options are to learn new Lucene: http://lucene.apache.org/java/3_4_0/api/all/overview-summary.html Or to use an older version of Lucene that supports the things you're trying to do: http://archive.apache.org/dist/lucene/java/2.9.4/ Try sticking with Java 6 for now. You will avoid plenty of headaches! I might suggest using the older version for now since it seems your tutorials and learning guides are using these older versions. Once you learn enough about Lucene, you can migrate your code to a newer version of Lucene. Jason -----Original Message----- From: lucenewbie [mailto:[email protected]] Sent: Thursday, September 29, 2011 2:01 PM To: [email protected] Subject: RE: Extreme Beginner Needs Lucene Help First, thanks for your reply. A few quick notes: - I have the book Lucene in Action. Additionally, I have all the source code for the book. They don't really address my problems. - I already configured the build path in Eclipse. - I was pretty sure that Lucene 3.4.0 addressed many of the Java 7 issues. Thanks for the explanation on deprecation, very informative. Here is the Indexer.java program given in the source for Lucene in Action. I edited this to run from a JAVA IDE instead of command line (but that only meant changing 2 files and removing the argument accepting). I'll mark errors with *****!!!******errors******!!!***** import org.apache.lucene.index.IndexWriter; import org.apache.lucene.analysis.standard.StandardAnalyzer; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; import java.io.File; import java.io.IOException; import java.io.FileReader; import java.util.Date; /** * This code was originally written for * Erik's Lucene intro java.net article */ public class Indexer { public static void main(String[] args) throws Exception { File indexDir = new File("indexDirectory"); File dataDir = new File("filestobeindexed"); long start = new Date().getTime(); int numIndexed = index(indexDir, dataDir); long end = new Date().getTime(); System.out.println("Indexing " + numIndexed + " files took " + (end - start) + " milliseconds"); } public static int index(File indexDir, File dataDir) throws IOException { if (!dataDir.exists() || !dataDir.isDirectory()) { throw new IOException(dataDir + " does not exist or is not a directory"); } IndexWriter writer = new IndexWriter("/index", new StandardAnalyzer(Version.LUCENE_CURRENT), true, IndexWriter.MaxFieldLength.LIMITED); *****!!!******The constructor IndexWriter(String, StandardAnalyzer, boolean, IndexWriter.MaxFieldLength) is undefined, MaxFieldLength.LIMITED is deprecated, MaxFieldLength is deprecated, Version cannot be resolved to a variable.******!!!***** writer.setUseCompoundFile(false); indexDirectory(writer, dataDir); int numIndexed = writer.docCount(); *****!!!******The method docCount() is undefined for the type IndexWriter******!!!***** writer.optimize(); writer.close(); return numIndexed; } private static void indexDirectory(IndexWriter writer, File dir) throws IOException { File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { File f = files[i]; if (f.isDirectory()) { indexDirectory(writer, f); // recurse } else if (f.getName().endsWith(".txt")) { indexFile(writer, f); } } } private static void indexFile(IndexWriter writer, File f) throws IOException { if (f.isHidden() || !f.exists() || !f.canRead()) { return; } System.out.println("Indexing " + f.getCanonicalPath()); Document doc = new Document(); doc.add(Field.Text("contents", new FileReader(f))); *****!!!******The method Text(String, FileReader) is undefined for the type Feild******!!!***** doc.add(Field.Keyword("filename", f.getCanonicalPath())); *****!!!******The method Text(String, String) is undefined for the type Feild******!!!***** writer.addDocument(doc); } } -- View this message in context: http://lucene.472066.n3.nabble.com/Extreme-Beginner-Needs-Lucene-Help-tp 3378560p3380039.html Sent from the Lucene - General mailing list archive at Nabble.com.
