lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <luc...@mikemccandless.com>
Subject Re: TVD, TVX and TVF files
Date Tue, 27 Mar 2012 18:12:47 GMT
The code seems OK on quick glance...

Are you closing the writer?

Are you hitting any exceptions?

Mike McCandless

http://blog.mikemccandless.com

On Tue, Mar 27, 2012 at 12:19 PM, Luis Paiva <luismpaiva@mail.telepac.pt> wrote:
> 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();
>      }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
> For additional commands, e-mail: java-user-help@lucene.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message