Search indexes aren't being updated when moving an entry from one channel to another in the CP
Hi Low,
We have a site where users are needing to move entries from one channel to another using the standard edit entry screen in the CP. We have two Low Search collections - one for each of the channels.
When a user moves an entry from one channel to another the Low Search indexes aren't being updated in the database. If I manually rebuild the indexes, it does update the index to include the entry in the new collection that the entry is now in, but it does not remove the entry from the old collection that it was in. I'm looking directly at the exp_low_search_indexes database table to double check what collections the entry is in.
Let me know if you need any more info here - thanks for taking a look.
Replies
Stephen 11 Mar 2016 18:34
Oops - I forgot to give you the versions of EE and Low Search that I'm using. This is with EE 2.10.1 and Low Search 4.3.1.
Low 12 Mar 2016 13:30
Hmm. I'll have to investigate. For now, if you alt-click the rebuild index link, that should delete all entries in the collection before rebuilding them.
Low 15 Mar 2016 10:09
Okay, you can try this in the latest Low Search version for EE2, which is 4.4.3:
Open up ext.low_search.php and look up line #100, which reads
Replace that line with these two:
That should fix the issue.
Stephen 5 Apr 2016 18:54
Hi Low,
Sorry for the huge delay on getting back to about this. I finally had a chance to test this out and it doesn't seem to be working exactly the way I hoped. If I edit an entry and change the channel it's assigned to through the CP it removes that entry from the exp_low_search_indexes table, but it doesn't re-add the entry with the new collection ID until I manually rebuild the indexes through Low Search. So until the user rebuilds those indexes those entries won't appear at all in any search results.
Would it be possible to have the entry just updated in the exp_low_search_indexes table when the user changes the channel for that entry and saves it so it reflects the new collection_id?
Thanks,
Stephen
Low 6 Apr 2016 20:14
Are you sure you've still got this line of code in place?
All references to the entry *should* be removed from the index before it's re-added. Since an entry can belong to multiple collections, it was the most sensible approach.
Stephen 7 Apr 2016 13:59
Hi Low,
Yes, I totally get why you need to remove the entry before re-adding it. I've tested some more and it looks like it actually is working properly, but I also had the Publisher Low Search extension on this site so that seems to be the reason the entry isn't being re-added. When that extension is disabled I see the entry being re-added in the database table with the new collection ID.
I'll take a look at that extension to see if there's something that needs to be updated there.
Thanks!
Stephen
Low 7 Apr 2016 14:33
Alright, keep me posted!
BoldMinded 8 Apr 2016 14:46
Low, would it be possible to get a hook in your delete() method, or between these two method calls?
ee()->low_search_index_model->delete($entry_id, 'entry_id');
ee()->low_search_index->build_by_entry($entry_id);
My extension isn't aware of any deletions, so I'm not sure how I can make the appropriate updates. Its going to be a few days before I can dig into this, so I'm not 100% sure if this is the issue, but its my first inclination.
Low 8 Apr 2016 14:59
*If* I add a hook, it won't be in the EE2 version, as that is feature frozen since the EE3-compatible version came out. :-/