Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update search index on tag delete/name change. #772

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

luku
Copy link
Contributor

@luku luku commented Dec 22, 2016

This is solution for issue #764
It also adds possibility to update search index (instead of always creating new from scratch). The update can be accomplished in 2 ways:

  1. using SQL (by selecting or aliasing record_type, record_id columns)
Zend_Registry::get('bootstrap')->getResource('jobs')
    ->sendLongRunning('Job_SearchTextIndex', array(
        'sql' => "SELECT record_type, record_id FROM table WHERE x=y"
    ));
  1. using array (maps record types and ids to update)
Zend_Registry::get('bootstrap')->getResource('jobs')
    ->sendLongRunning('Job_SearchTextIndex', array(
        'records' => array(
            'Item' => array(1,2,3,4, ...),
            'Collection' => array(1,2,3,4, ...),
        )
    ));

@zerocrates I know you said it is too big update for version 2.5, but I think it's really practical to be able to update the search index via core job and it doesn't feel like a dangerous update or complicated one.

@luku
Copy link
Contributor Author

luku commented Dec 22, 2016

Well, I see another use case for search index update where none of suggested approaches really works; When adding new record types that should be searchable in admin/settings/edit-search, it should update/add this new record type into search index. What would be best way then? Using array as previously, but instead of array of ids it would accept Boolean true and index all records for those record types:

Zend_Registry::get('bootstrap')->getResource('jobs')
    ->sendLongRunning('Job_SearchTextIndex', array(
        'records' => array(
            'Item' => true,
            'Collection' => true,
        )
    ));

?? Any ideas?

@luku luku changed the title Update search index on tag name change. Update search index on tag delete/name change. Apr 5, 2017
@luku
Copy link
Contributor Author

luku commented Apr 5, 2017

I noticed the search index is not updated on tag delete either, so I added possibility for it as well, but 2 concerns popped up...

  1. When deleting, it's not possible to use SQL. Only map of record types and ids is usable. So I wonder if we should change the data type for args column into mediumtext or longtext?
  2. When doing batch-delete of tags (via some plugin), the search index update may be very CPU/memory intensive and not really optimal. Search indexing of same item with 3 tags being deleted will run 3 times, instead of once. Every deleted tag will spawn new parallel process. Finally, even DB table processes may get filled quickly and take lot of space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant