Manage this page

1. Back to lucene notes

2. Display

3. Feedback

	/**
	 * Given a unique key such as a URL, locate the document
	 * and return its term frequency vector.
	 * 
	 * return null if the key is not found.
	 * 
	 * When a document is located its docnum is used to retrieve the
	 * term frequency vector
	 * 
	 * @param url
	 * @return
	 * @throws IOException
	 */
	public TermFreqVector getTermVectors(String url) throws IOException
	{
		//Locate the matching document
		LuceneIndex li = LuceneIndexHolder.getLuceneIndex();
		int docnum = li.locateIndexedUrlDocNumber(url);
		
		//Document not found
		if (docnum == -1)
		{
			return null;
		}
		
		//Document found
		IndexReader reader = li.getReader();
		
		//Log.log("Index has " + reader.numDocs() + " documents.");
		TermFreqVector tfv = reader.getTermFreqVector(docnum,"content");
		return tfv;
	}