What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread java8964 java8964
Hi, In our application, we will allow the user to create a primary key defined in the document. We are using lucene 2.9. In this case, when we index the data coming from the client, if the metadata contains the primary key defined, we have to do the search/update for every row based on the pr

Re: What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread Jake Mannix
The usual way to do this is to use: IndexWriter.updateDocument(Term, Document) This method deletes all documents with the given Term in it (this would be your primary key), and then adds the Document you want to add. This is the traditional way to do updates, and it is fast. -jake On Mo

Re: What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread Erick Erickson
What is the form of the unique key? I'm a bit confused here by your comment: "which can contain one or multi fields". But it seems like IndexWriter.deleteDocuments should work here. It's easy if your PKs are single terms, there's even a deleteDocuments(Term[]) form. But this really *requires* that

Re: What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread Erick Erickson
Sorry, forgot to add "then re-add the documents in question". On Mon, Nov 16, 2009 at 12:45 PM, Erick Erickson wrote: > What is the form of the unique key? I'm a bit confused here by your > comment: > "which can contain one or multi fields". > > But it seems like IndexWriter.deleteDocuments shoul

RE: What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread java8964 java8964
What I mean is that for one index, client can defined multi field in the index as the primary key (composite key). > Date: Mon, 16 Nov 2009 12:45:40 -0500 > Subject: Re: What is the best way to handle the primary key case during > lucene indexing > From: erickerick...@gm

RE: What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread java8964 java8964
But can IndexWriter.updateDocument(Term, Document) handle the composite key case? If my primary key contains field1 and field2, can I use one Term to include both field1 and field2? Thanks > Date: Mon, 16 Nov 2009 09:44:35 -0800 > Subject: Re: What is the best way to handle the prima

Re: What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread Jake Mannix
09 09:44:35 -0800 > > Subject: Re: What is the best way to handle the primary key case during > luceneindexing > > From: jake.man...@gmail.com > > To: java-user@lucene.apache.org > > > > The usual way to do this is to use: > > > >IndexWriter.upd

Re: What is the best way to handle the primary key case during lucene indexing

2009-11-16 Thread Erick Erickson
nd field2? > > > > Thanks > > > > > Date: Mon, 16 Nov 2009 09:44:35 -0800 > > > Subject: Re: What is the best way to handle the primary key case during > > luceneindexing > > > From: jake.man...@gmail.com > > > To: java-user@lucene.apache