Tim Andrews
Tim Andrews

Reputation: 43

Lucene.NET: Retrieving all the Terms used in a particular Document

Is there a way to itterate through all of the terms held against a particular document in a Lucene.NET index?

Basically I want to be able to retrieve a Document from the Index based on it's ID and then find the frequency with which each Term is used in that Document. Does anyone know a way to do this?

I can find the number of Documents that match a particular Term but not the Terms contained within a particular Document.

Many thanks,

Tim

Upvotes: 4

Views: 1285

Answers (1)

bajafresh4life
bajafresh4life

Reputation: 12843

In Lucene Java, at least, one of the options when indexing a document is storing the term frequency vector. The term frequency vector is simply a list of all the terms in a given field of a document, and how often each of those terms was used. Getting the term frequency vector at runtime involves calling a method in the IndexReader with the Lucene ID of the document in question.

Upvotes: 3

Related Questions