lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ashwin kumar" <gv.ash...@gmail.com>
Subject hi compile error
Date Tue, 13 Feb 2007 05:34:49 GMT
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.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message