Omeka icon indicating copy to clipboard operation
Omeka copied to clipboard

Search index is not updated after renaming a tag

Open luku opened this issue 8 years ago • 1 comments

If you try to edit tag name on admin/tags page, it doesn't update the search index for tagged items, so you can still find the old tag when searching (global/simple search). I think this should be done in core. But not sure how. The current code in TagsController is assigning new value/name directly, so there is no simple way to compare old value against new value in record beforeSave/afterSave callbacks, unless we fetch the old tag in beforeSave, update some boolean flag to let us know that in afterSave callback we should find all tagged items and save them (to trigger the search index update). So I wonder if we shouldn't alter the code in TagsController into: $oldTag->setPostData(array('name' => trim($_POST['value']), 'changed' => (trim($oldName) != $newName))); and then in models/Tag afterSave callback add the logic for updating all tagged items if the tag name changed. For plugins (i.e. ExhibitBuilder) that are using tags as well, it would require similar logic in after_save_tag hook. Does it sound good, or do you have other ideas? Another concern - the number of tagged records might be a quite high, so do we need to run it via long running job? And if so, should we extend Job_SearchTextIndex to work both as indexing from scratch (current version) and index update for specific record_type + record_id?

luku avatar Dec 06 '16 08:12 luku

Your concern about the number of records needing to be updated is legitimate: it'd probably have to be a job here.

I don't see this as something small enough to fit into 2.5, which I'm trying to wrap up.

I'm somewhat tempted to say that the solution is to just tell people to reindex after renaming tags, but that's obviously not optimal.

zerocrates avatar Dec 08 '16 18:12 zerocrates