public static org.apache.lucene.document.Document | Document(java.io.File f)Makes a document for a File.
The document has a single field:
-
contents --containing the full contents
of the file, as a Text field;
TextDocument textDoc = new TextDocument(f);
// make a new, empty document
Document doc = new Document();
doc.add(new Field("title", f.getName(), Field.Store.YES, Field.Index.TOKENIZED));
doc.add(new Field("contents", textDoc.getContents(), Field.Store.YES, Field.Index.TOKENIZED));
doc.add(new Field("rawcontents", textDoc.getContents(), Field.Store.YES, Field.Index.NO));
// return the document
return doc;
|