You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Maryam <mk...@yahoo.com> on 2007/03/23 01:34:56 UTC
problem in reading an index
Hi,
I have written this piece of code to read the index,
mainly to see what terms are in each document and what
the frequency of each term in the document is. This
piece of code correctly calculates the number of docs
in the index, but I dont know why variable
myTermFreq[] is null. Would you please let me know
your idea bout it?
IndexReader reader = IndexReader.open(myInd);
for (int docNo = 0; docNo < reader.numDocs(); docNo++)
{
TermFreqVector myTermFreq[] =
reader.getTermFreqVectors(docNo);
if (myTermFreq != null) {
for (int i = 0; i < myTermFreq.length; i++) {
int freq[] = myTermFreq[i].getTermFrequencies();
//String terms[]= myTermFreq[i].getTerms();
for (int j=0;j<terms.length;j++)
System.out.println("term"+terms[j]);
for (int j=0;j<freq.length;j++)
System.out.println("freq:"+ freq[j]);
}
}
}
Thanks
____________________________________________________________________________________
8:00? 8:25? 8:40? Find a flick in no time
with the Yahoo! Search movie showtime shortcut.
http://tools.search.yahoo.com/shortcuts/#news
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: problem in reading an index
Posted by karl wettin <ka...@gmail.com>.
23 mar 2007 kl. 02.09 skrev Daniel Noll:
> Maryam wrote:
>> Hi, I have written this piece of code to read the index,
>> mainly to see what terms are in each document and what
>> the frequency of each term in the document is. This
>> piece of code correctly calculates the number of docs
>> in the index, but I don’t know why variable
>> myTermFreq[] is null. Would you please let me know
>> your idea bout it?
>
> From TFJD:
> Return an array of term frequency vectors for the specified
> document.
> The array contains a vector for each vectorized field in the
> document. Each vector contains terms and frequencies for all terms
> in a given vectorized field. If no such fields existed, the method
> returns null.
>
> i.e. you may not have stored the term vectors when indexing the data.
This thread might be of interest:
http://www.nabble.com/Resolving-term-vector-even-when-not-stored--
tf3412160.html#a9507268
--
karl
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org
Re: problem in reading an index
Posted by Daniel Noll <da...@nuix.com>.
Maryam wrote:
> Hi,
>
> I have written this piece of code to read the index,
> mainly to see what terms are in each document and what
> the frequency of each term in the document is. This
> piece of code correctly calculates the number of docs
> in the index, but I don’t know why variable
> myTermFreq[] is null. Would you please let me know
> your idea bout it?
From TFJD:
Return an array of term frequency vectors for the specified document.
The array contains a vector for each vectorized field in the
document. Each vector contains terms and frequencies for all terms
in a given vectorized field. If no such fields existed, the method
returns null.
i.e. you may not have stored the term vectors when indexing the data.
Daniel
--
Daniel Noll
Nuix Pty Ltd
Suite 79, 89 Jones St, Ultimo NSW 2007, Australia Ph: +61 2 9280 0699
Web: http://nuix.com/ Fax: +61 2 9212 6902
This message is intended only for the named recipient. If you are not
the intended recipient you are notified that disclosing, copying,
distributing or taking any action in reliance on the contents of this
message or attachment is strictly prohibited.
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org