lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bhavin Pandya" <bhav...@rediff.co.in>
Subject Re: How to open IndexWriter to append document?
Date Mon, 15 Jan 2007 09:26:12 GMT
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" <zhouchengly@gmail.com>
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 <DORONC@il.ibm.com>:
>>
>> You should instantiate the writer with create=true :
>>
>>       IndexWriter(store, StandardAnalyzer, True )
>>
>> Because with create=False, an existing index is expected.
>>
>> David <zhouchengly@gmail.com> 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: java-user-unsubscribe@lucene.apache.org
>> For additional commands, e-mail: java-user-help@lucene.apache.org
>>
>>
>
>
> -- 
> David
> 


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