lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nitin gopi <nitdaii...@gmail.com>
Subject Re: error in code
Date Fri, 06 Mar 2009 08:57:25 GMT
hi Ganesh,
the program still gives error in the second line . it says that  *cannot
find symbol * .I think that we are initializing the object of Field class
two times, that is why we are getting error.
 document.add(new Field("content",textReader));
 document.add(new Field("path",textFiles[i].getPath()));

Thanks,
Nitin Gopi

On Fri, Mar 6, 2009 at 11:01 AM, Ganesh <emailgane@yahoo.co.in> wrote:

> Hello gopi,
>
> My comments.
>
>  if(textFiles[i].isFile() > textFiles[i].getName().endsWith(".txt")){
>>
>   && should be used.
>
>  *document.add(Field.Text("content",textReader));
>>
>    document.add(new Field("content", textReader);
>
>  document.add(Field.Text("path",textFiles[i].getPath()));*
>>
>   document.add(new Field("path", textFiles[i].getPath());
>
> Regards
> Ganesh
>
> ----- Original Message ----- From: "nitin gopi" <nitdaiict8@gmail.com>
> To: <java-user@lucene.apache.org>
> Sent: Friday, March 06, 2009 8:24 AM
> Subject: error in code
>
>
>
>  Hi all,
>>
>> I am getting error in running this code. Can somebody please tell me what
>> is the problem? The code is given below. The bold lines were giving error
>> as
>> *cannot find symbol *
>>
>>
>>
>> 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{
>>  //fileDir is the directory that contains the text files to be indexed
>>  File   fileDir  = new File("C:\\files_to_index ");
>>
>>  //indexDir is the directory that hosts Lucene's index files
>>  File   indexDir = new File("C:\\luceneIndex");
>>  Analyzer luceneAnalyzer = new StandardAnalyzer();
>>  IndexWriter indexWriter = new IndexWriter(indexDir,luceneAnalyzer,true);
>>  File[] textFiles  = fileDir.listFiles();
>>  long startTime = new Date().getTime();
>>
>>  //Add documents to the index
>>  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());
>>  }
>> }
>>
>> Regards ,
>> Nitin Gopi
>>
>>
> Send instant messages to your online friends http://in.messenger.yahoo.com
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>
>

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