I don't know what Analyzer. I'm new to all this. This is all I have so far. As far as the location of the index, this is just for test purposes.
Brittany -----Original Message----- From: Otis Gospodnetic [mailto:[EMAIL PROTECTED] Sent: Friday, August 08, 2008 1:13 PM To: java-user@lucene.apache.org Subject: Re: Need help searching What Analyzer is your searcher using? C:\\ as the index location sounds .... "super funky". Why not C:\\MyIndex , so your index files are not all mixed up with whatever lives in C:\\ Otis -- Sematext -- http://sematext.com/ -- Lucene - Solr - Nutch ----- Original Message ---- > From: Brittany Jacobs <[EMAIL PROTECTED]> > To: java-user@lucene.apache.org > Sent: Friday, August 8, 2008 11:20:11 AM > Subject: Need help searching > > 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: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]