lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Otis Gospodnetic <otis_gospodne...@yahoo.com>
Subject Re: Need help searching
Date Fri, 08 Aug 2008 17:13:13 GMT
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 <bjacobs@jbmanagement.com>
> 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: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org


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