lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brittany Jacobs" <bjac...@jbmanagement.com>
Subject Need help searching
Date Fri, 08 Aug 2008 15:20:11 GMT
I want to search all the documents for a string.
So I have the following.  But Hits isn't returning anything.
What am I doing wrong?  Thanks in advance.


File f = new File("AddressData.txt");
IndexWriter writer;
try {
writer = new IndexWriter("C:\\", new StandardAnalyzer(), true);
FileInputStream fstream = new FileInputStream("AddressData.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
while ((strLine = br.readLine()) != null)   {
Document doc = new Document();
doc.add(new Field("filename", f.getCanonicalPath(), Field.Store.YES,
Field.Index.TOKENIZED));
doc.add(new Field("line", strLine,                  Field.Store.YES,
Field.Index.TOKENIZED));
writer.addDocument(doc);
}
in.close();
writer.close();

IndexSearcher iSearch = new IndexSearcher("C:\\");

Term term = new Term("line", "KOREA");
PhraseQuery query = new PhraseQuery();
query.add(term);
Hits hits = iSearch.search(query);
}

} catch (CorruptIndexException e) {
e.printStackTrace();
} catch (LockObtainFailedException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

---
Brittany 




---------------------------------------------------------------------
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