lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From luismpaiva <luismpa...@mail.telepac.pt>
Subject Term Vector files situation
Date Wed, 21 Mar 2012 23:12:46 GMT
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


Mime
View raw message