lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ranjit Kumar <>
Subject FW: Re: lucene3.0.2: getting incorrect no. of occurrence in file
Date Wed, 08 Dec 2010 05:33:46 GMT
                Thanks for your replay!!!
                                Below is code I am using for search
                                                String line="sql server";
IndexReader reader = File(indexpath)), true);   // contains
index file path
                Searcher searcher = new IndexSearcher(reader);
                Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_CURRENT);
QueryParser parser = new QueryParser(Version.LUCENE_CURRENT, field, analyzer);
if (line != null) {
                line = line.trim();
                Query query = parser.parse(line);
                int n = 100;
                TopDocs docs =, n);
                TermDocs termDocs = reader.termDocs(new Term(field, line. toLowerCase()));
                System.out.println("   " + docs.totalHits + " total matching documents\n");
                for (int i = 0; i < docs.scoreDocs.length; i++) {
                    int totalFreq = 0;
                    Document document = reader.document(docs.scoreDocs[i].doc);
                    String path = document.get("path");
                    System.out.println("path>>" + path);
                    totalFreq = termDocs.freq();
   System.out.println("totalFreq >>" + totalFreq);


Thanks & Regards,
Ranjit Kumar
Private, Confidential and Privileged. This e-mail and any files and attachments transmitted
with it are confidential and/or privileged. They are intended solely for the use of the intended
recipient. The content of this e-mail and any file or attachment transmitted with it may have
been changed or altered without the consent of the author. If you are not the intended recipient,
please note that any review, dissemination, disclosure, alteration, printing, circulation
or Transmission of this e-mail and/or any file or attachment transmitted with it, is prohibited
and may be unlawful. If you have received this e-mail or any file or attachment transmitted
with it in error please notify OTS Solutions at ===================================================================================================

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message