lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kasun Perera <>
Subject Getting the frequencies by corresponding order of documents were indexed
Date Fri, 11 May 2012 07:58:25 GMT
I have collection of documents (say 10 documents)and i'm indexing them this
way, by storing the term vector

StringReader strRdElt = new StringReader(content);

    Document doc = new Document();

    String docname=docNames[docNo];

    doc.add(new Field("doccontent", strRdElt, Field.TermVector.YES));

    IndexWriter iW;
    try {

        NIOFSDirectory dir = new NIOFSDirectory(new File(pathToIndex)) ;

        iW = new IndexWriter(dir, new IndexWriterConfig(Version.LUCENE_35,

                new StandardAnalyzer(Version.LUCENE_35)));



After Index all the documents, i'm getting the term-frequencies of each
document this way

IndexReader re =
File(pathToIndex)), true) ;
TermFreqVector termsFreq[];
for(int i=0;i<noOfDocs;i++){
        termsFreq[i] = re.getTermFreqVector(i, "doccontent");


my problem is i'm not getting the termfreqncy vector correspondingly. Say
for 2nd document that I have indexed i'm getting it's corresponding
termfrequncies and terms at "termsFreq[9]"

What is the reason for that?, how can I get the corresponding
termfrequncies by the order that I have indexed the documents?


Kasun Perera

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