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: lucene not returning correct results eventhough search query is present
Date Thu, 19 Nov 2009 05:50:41 GMT
Hi,


Please use java-user list for user questions.

Are you sure the file got fully indexed in the first place?  Use Luke to check.

Also, see:
IndexWriter.MaxFieldLength

Otis
--
Sematext is hiring -- http://sematext.com/about/jobs.html?mls
Lucene, Solr, Nutch, Katta, Hadoop, HBase, UIMA, NLP, NER, IR



----- Original Message ----
> From: udayKIRAN <udayacc2005@yahoo.com>
> To: java-dev@lucene.apache.org
> Sent: Thu, November 19, 2009 12:08:32 AM
> Subject: lucene not returning correct results eventhough search query is present
> 
> 
> hi,
> i am lucene to search log files. but i am not able search any words in the
> file that are after a certain line. i am using file reader to serach. Lucene
> is searching only upto a certain line in the file. can anyone hepl me.
> these are few lines of my code
> IndexWriter writer =
>                 new IndexWriter(idx, new StandardAnalyzer(), true);
> writer.addDocument(createDocument("filename",
>              new FileReader(new File(filepath))));
> writer.optimize();
> writer.close();
> public static Document createDocument(String folderpath, FileReader fr) {
>         Document doc = new Document();        
>         doc.add( new Field("title", folderpath,Field.Store.YES,
> Field.Index.TOKENIZED
>                ));      
>         doc.add(new Field("content", fr  ));
> 
>         return doc;
>     }
> //search function
>   public static void search(Searcher searcher, String queryString)
>         throws ParseException, IOException {      
>         Query query = new QueryParser("content",new
> StandardAnalyzer()).parse(queryString );
>         // Search for the query
>         Hits hits = searcher.search(query  );
>        TopDocs topdocs = searcher.search(query ,1  );
>        //System.out.println(topdocs.);
>         // Examine the Hits object to see if there were any matches
>         int hitCount = hits.length();
>         if (hitCount == 0) {
>             System.out.println(
>                 "No matches were found for \"" + queryString + "\"");
>         }
>         else {
>             System.out.println("Hits for \"" +
>                 queryString + "\" were found in files by:");
>             for (int i = 0; i < hitCount; i++) {
>                 Document doc = hits.doc(i);                
>                 System.out.println("  " + (i + 1) + ". " +
> doc.get("title"));
>             }
>         }
>         System.out.println();
>     }
> -- 
> View this message in context: 
> http://old.nabble.com/lucene-not-returning-correct-results-eventhough-search-query-is-present-tp26420491p26420491.html
> Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-dev-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