Some problems with lucene in searching

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Some problems with lucene in searching

sriram Thota

   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();
   // here the contents of the file "file.txt" are converted to document
   document.add(Field.Text("sFileDoc",new FileReader (fFile)));
   }catch(FileNotFoundException fnfe) {
return document;

public static void indexDocs(IndexWriter writer , File file) throws
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]));
     }else {
        sFile = sFile+file.getName();
if(files.length == iCount){
   out = new BufferedWriter(new FileWriter(fFile));
   //here iam writing the names of files to file.txt
   //here iam converting the file.txt to document object
   doc = createDocument(fFile);
   }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

Please help me.


To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]