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-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-dev-h...@lucene.apache.org

Reply via email to