Hi david,

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.

Please check Lucene api for IndexReader...

It has one method which u can use before opening IndexWriter..."indexExists(Directory directory)"

- Bhavin pandya


----- Original Message ----- From: "David" <[EMAIL PROTECTED]>
To: <java-user@lucene.apache.org>
Sent: Monday, January 15, 2007 2:06 PM
Subject: Re: How to open IndexWriter to append document?


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?
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