David <[EMAIL PROTECTED]> wrote on 15/01/2007 00:36:28:

> Thanks, I think I did not describe my problem exactly.
> What I want to do is:
>      if the index file exist, append document
>      if the index file does not exist, create a new , empty index file.
> How can I implement that?

If this is what you need, this (Lucene Java) conostructor would do:
   IndexWriter(File path, Analyzer a)
          Constructs an IndexWriter for the index in path, creating it
first if it does not already exist, otherwise appending to the existing
index.

Your current code really cannot work, becuase for FSDirectory.get(),
create=true, which erases everything first, and for IndexWriter(),
create=false, which expects an existing index.

> Appreciate your help!
>
>
> 2007/1/15, Doron Cohen <[EMAIL PROTECTED]>:
> >
> > You should instantiate the writer with create=true :
> >
> >       IndexWriter(store, StandardAnalyzer, True )
> >
> > Because with create=False, an existing index is expected.
> >
> > David <[EMAIL PROTECTED]> wrote on 14/01/2007 23:56:23:
> >
> > > Hi all:
> > >     I want first erase the original index and then create an index
for
> > > appending, I use the following python code using ports pyLucene.
> > >
> > >    def store(doc)
> > >         store = PyLucene.FSDirectory.getDirectory("index", True)
> > >         writer = PyLucene.IndexWriter(store, StandardAnalyzer, False
) #
> > > error occurs in this line!
> > >         writer.addDocument(doc);
> > >         writer.optimize()
> > >         writer.close()
> > >    if __name__ == '__main__':
> > >         store(doc1)
> > >         store(doc2)
> > >
> > >     But I get the following errors:
> > >
> > >  File "D:\work\contentstore\contentstore\backends\lucene\base.py",
line
> > 30,
> > > in store
> > >     writer = PyLucene.IndexWriter(store, self.analyzer, False )
> > > PyLucene.JavaError: java.io.FileNotFoundException:
> > > D:\work\contentstore\contentstore\backends\lucene\index\segments: The
> > system
> > > cannot find the file specified.
> > >
> > >     How to fix it?
> > > Appreciate your help!
> > >
> > > --
> > > David
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
>
>
> --
> David


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to