lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sriram Thota <sth...@sharelogicinc.com>
Subject Some problems with lucene in searching
Date Mon, 13 Jun 2005 06:12:20 GMT
Hi,

   I am working on lucene.I had seen ur suggestion about lucene in google 
search.Iam facing some problems in searching.Please go through my sample code 
and suggest me where i had gone wrong.

I will be thankful to you.



This is my sample code:

private static Document createDocument(File fFile) {
Document document = new Document();
try{
   // here the contents of the file "file.txt" are converted to document 
object.
   document.add(Field.Text("sFileDoc",new FileReader (fFile)));
   }catch(FileNotFoundException fnfe) {
   ;
   }
return document;
}


public static void indexDocs(IndexWriter writer , File file) throws
IOException{
String[] files = new String[]{};
File fFile = new File("file.txt");
Document doc = new Document();
int iCount = 0;
BufferedWriter out = null;
if (file.canRead()) {
    if (file.isDirectory()) {
    files = file.list();
    if (files != null) {
        for (int i = 0; i < files.length; i++) {
        indexDocs(writer, new File(file, files[i]));
        iCount++;
        }
     }
     }else {
        sFile = sFile+file.getName();
     }
   }
if(files.length == iCount){
try{
   out = new BufferedWriter(new FileWriter(fFile));
   //here iam writing the names of files to file.txt
   out.write(sFile.toLowerCase());
   //here iam converting the file.txt to document object
   doc = createDocument(fFile);
   writer.addDocument(doc);
   out.close();
   }catch(Exception excep){
   ;
   }
}
}

   Here i am able to write the names of the files in file.txt and able to 
index file.txt and before indexing i had converted the file names to 
lowercase,but iam not able to search with filenames.Iam giving the complete 
filename.

Please help me.


                                                                       
Sriram.T


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message