Hi ashwin,
I think there is error in your import statement...
import org.apache.lucene.document.Field;
Thanks.
Bhavin pandya
----- Original Message -----
From: "ashwin kumar" <[EMAIL PROTECTED]>
To: <java-user@lucene.apache.org>
Sent: Tuesday, February 13, 2007 11:04 AM
Subject: hi compile error
hi all my name is ashwin i am trying to compile this program but its not
getting compiled the error msg follows the code which is below
import java.io.File;
import java.io.FileReader;
import java.io.Reader;
import java.util.Date;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field.*;
import org.apache.lucene.index.IndexWriter;
/**
* This class demonstrates the process of creating an index with Lucene
* for text files in a directory.
*/
public class TextFileIndexer
{
public static void main(String[] args) throws Exception
{
File fileDir = new File("C:\\files_to_index ");//fileDir is the
directory that contains the text files to be indexed
File indexDir = new File("C:\\luceneIndex"); //indexDir is the
directory that hosts Lucene's index files
Analyzer luceneAnalyzer = new StandardAnalyzer();
IndexWriter indexWriter = new
IndexWriter(indexDir,luceneAnalyzer,true);
File[] textFiles = fileDir.listFiles();
long startTime = new Date().getTime();
for(int i = 0; i < textFiles.length; i++)
{
if(textFiles[i].isFile() &&
textFiles[i].getName().endsWith(".txt"))
{
System.out.println("File " +
textFiles[i].getCanonicalPath()+ " is being indexed");
Reader textReader = new FileReader(textFiles[i]);
Document document = new Document();
document.add(Field.Text("content",textReader));
document.add(Field.Text("path",textFiles[i].getPath()));
indexWriter.addDocument(document);
}
}
indexWriter.optimize();
indexWriter.close();
long endTime = new Date().getTime();
System.out.println("It took " + (endTime - startTime)
+ " milliseconds to create an index for the files in the
directory "
+ fileDir.getPath());
}
}
error msg:
--------------------Configuration: <Default>--------------------
D:\ASHWIN\testing\searching\TextFileIndexer.java:40: cannot find symbol
symbol : variable Field
location: class TextFileIndexer
document.add(Field.Text("content",textReader));
^
D:\ASHWIN\testing\searching\TextFileIndexer.java:41: cannot find symbol
symbol : variable Field
location: class TextFileIndexer
document.add(Field.Text("path",textFiles[i].getPath()));
^
2 errors
Process completed.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]