lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kostas Vel" <>
Subject Index all the files in a directory
Date Thu, 13 Apr 2006 09:54:57 GMT
Hi, I have a problem that has to do more with java than with lucene.
I have a folder that has about 524 text files (.txt) that I want to index.
I have made a program that works very well. It does indexing searching
          IndexWriter writer;
          GreekAnalyzer anal = new GreekAnalyzer();
          try {
            writer = new IndexWriter(indexPath,anal, true);
            for (int i = 1; i <=524; i++) {

              File indexFile = new File("/database/" +i+ ".txt");
              InputStream fis = new FileInputStream(indexFile);
               * We use a Document with four fields: the file path, the last
modified date
               * the length of the file  and one the file's contents.
              Document doc = new Document();

              doc.add(Field.UnIndexed("path", indexFile.getPath()));
              doc.add(Field.UnIndexed("modified",new Date(
              doc.add(Field.Text("text", (Reader) new

My problem is that I want to delete the for loop and write the program in a
way to read all the files I want to index and there are in a folder.
I have other folders as well that have txt files as well but they are not
524 so I can not use the for loop.
I hope that you understand what I mean because I don't use the English
language very well.

Thank you very much

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