You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by luismpaiva <lu...@mail.telepac.pt> on 2012/03/22 00:12:46 UTC
Term Vector files situation
Hey all,
i'm in my first steps in Lucene.
I was trying to index some txt files, and my program doesn't construct the
term vector files. I would need these files. (.tvd, .tvx, .tvf)
I'm attaching my code so anyone can help me.
Thank you all in advance!
Sorry if i'm repeating the question, but i couldn't find the answer to it.
public void indexFileOrDirectory(String fileName) throws IOException {
addFiles(new File(fileName));
int originalNumDocs = writer.numDocs();
for (File f : queue) {
FileReader fr = null;
try {
Document doc = new Document();
fr = new FileReader(f);
doc.add(new Field("contents", fr));
doc.add(new Field("path", fileName, Field.Store.YES,
Field.Index.NOT_ANALYZED));
String xpto = "xpto1 xpto2 xpto3";
doc.add(new Field("contents2", xpto, Field.Store.YES,
Field.Index.ANALYZED, Field.TermVector.YES));
writer.addDocument(doc);
System.out.println("Added: " + f);
} catch (Exception e) {
System.out.println("Could not add: " + f);
} finally {
fr.close();
}
--
View this message in context: http://lucene.472066.n3.nabble.com/Term-Vector-files-situation-tp3847122p3847122.html
Sent from the Lucene - Java Developer mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org