Welcome Guest, Not a member yet? Register   Sign In
Updating documents with Zend_Search_Lucene

Hi everyone.

I just wanted some input from anyone that uses Lucene. I need to update a single field in a lot of documents, and I understand that I need to delete the old document, and insert a new document, but I am looking for a simple make the existing document editable so that I can just reinsert it. The way Lucene's document objects have been designed, prevents you from editing fields, so I can't just change it and then stick it into the index (or at least I haven't figured out how yet). I'd be interested to hear how everyone else does this.

I was thinking of having a method that converts a document result back into the original array where the document data was extracted, so I could just edit the array, and then create a new document from it, but this idea is not without it's flaws and hidden complexities.

Any thoughts appreciated.

When I need to edit a field in a Lucene document I modify my method that handles the creation of the index and just rerun the script.

I don't know where your data came from (database, XML/JSON file, etc) or how you created your index, but it would probably be quicker to just rebuild the index with the change than it would be to implement your idea of converting a document back, editing, and then creating it again.

Hi, thanks a lot for your reply. The problem I've realised I have is that I can't copy and UnStored field.

I am trying to use Lucene to index my forum posts, in order to be able to delete things from the index, I need to store the forum ID and topic ID of the post, in a Lucene Document as a keyword. This means I can easily delete the posts belonging to an entire topic or even forum. The problem I'm trying to solve at the moment, is how to move a forum.

I can get a list of all of the posts, but since the post body is only indexed, and not stored, I'd need to get the contents for every post in that forum/topic, and add the all to the index. I think that what I need, is some way to associate the old indexed text with the new document. I don't think this is possible, however.

As I'm not an experience Lucene user, I'd also be very interested to see some of the stats from your own index(es), for example, how large it is, how long it takes to reindex (if you ever do), and how long queries generally take.

Many thanks for your comments.

Theme © iAndrew 2016 - Forum software by © MyBB