Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Lucene: Java-User

Re: lucene not returning correct results eventhough search query is present

 

 

Lucene java-user RSS feed   Index | Next | Previous | View Threaded


otis_gospodnetic at yahoo

Nov 18, 2009, 9:50 PM

Post #1 of 1 (285 views)
Permalink
Re: lucene not returning correct results eventhough search query is present

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 [at] yahoo>
> To: java-dev [at] lucene
> 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 [at] lucene
> For additional commands, e-mail: java-dev-help [at] lucene


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe [at] lucene
For additional commands, e-mail: java-user-help [at] lucene

Lucene java-user RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.