public abstract TermPositions ( ) : TermPositions | ||
return | TermPositions |
IndexReader reader = DirectoryReader.Open(directory); Document doc = reader.Document(0); // retrieve first indexed document reader.Close();
IndexReader reader = DirectoryReader.Open(directory); TermPositions termPositions = reader.TermPositions(new Term("content", "example")); while (termPositions.Next()) { Console.WriteLine("Document ID: {0}, Term Position: {1}", termPositions.Doc, termPositions.NextPosition()); } reader.Close();This code creates an instance of TermPositions class by passing the term (in this case, "example") and a field name ("content") to the reader.TermPositions() method. It then loops through all the documents containing the term and prints out the document ID and the position of the term within the document.
public abstract TermPositions ( ) : TermPositions | ||
return | TermPositions |