You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by MM...@LEVI.com on 2003/05/22 14:18:36 UTC
Great Lucene!!!
Hi, me again, but I don't find something that could help me in the Lucene's
examples. Also I verified that the all files were indexed. Can somebody help
me, Thanks
Michel
from: Machado, Michel
Sent: Tuesday, May 20, 2003 9:09 PM
To: 'Lucene Users List'
Subject: Lucene i like it!!!
Hi guys,
I am new in Lucene but i like a lot. I am trying to develop a search
engine.
I have two problems:
First
I did a program for indexing files, here the code:
public void indexFile(String filename) throws Exception {
IndexWriter writer;
writer = new IndexWriter(path, new SimpleAnalyzer(), false);
InputStream is = new FileInputStream(filename);
Document doc = new Document();
doc.add(Field.UnIndexed("path", filename));
doc.add(Field.Text("body", (Reader) new InputStreamReader(is)));
writer.addDocument(doc);
is.close();
writer.close();
}
when I do a search I receive severals links and the first is the link that I
need. The others link appear because the query have some letter or number
that match with the name of content of the file??? I don't know. I need a
help.
Second
I did a program for indexing a directory recursivily (my English is very
poor, I hope that you understand), here the code:
public void indexDirectory(String dir) throws Exception {
File file = new File(dir);
if (file.isDirectory()) {
File[] f = file.listFiles();
for (int x = 0; x < f.length; x++) {
if (f[x].isDirectory()) {
System.out.println("DIRECTORY:" +
f[x].getName());
// search recursive in directory
indexDirectory(f[x].getAbsolutePath());
} else {
System.out.println(" FILE: " +
f[x].getName());
indexFile(f[x].getAbsolutePath());
}
}
} else {
System.out.println(" FILE: " + file.getName());
indexFile(file.getAbsolutePath());
}
}
When I do a search after to do an indexing of a directory with files only I
have the FIRST problem. But when I do a search after to do an indexing of a
directory with subdirectories and this subdirectories with others
subdirectories and this others subdirectories with files, is not possible
to find the file that I want. What happens, there is an error in my code???
Some help I will appreciate.
Regards,
Michel