-
Notifications
You must be signed in to change notification settings - Fork 62
Description
Describe the bug
When you run the wp-cli command wp algolia reindex --all
the index would still be cleared.
This happens because when it re-indexes the first batch, it checks if the index exists.
And inside that functionality, it also empties the index if the index already existed.
To Reproduce
Steps to reproduce the behavior:
- In your terminal, run
wp algolia reindex --all
- Visit algolia backend interface, see you have indexed items.
- Run
wp algolia reindex --all
- While the command is running, refresh the algolia backend interface
- You will see the index has been cleared, and less items are in the index (and going up in amount as more content is being indexed)
Expected behavior
Index should not be cleared when the --clear
flag has not been specified.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: MacOS
- Browser chrome
- Version 131.0.6778.109 (Official Build) (arm64)
Smartphone (please complete the following information):
Cannot run wp-cli on smartphone
Additional context
Add any other context about the problem here.
Fix would be to add add_filter( 'algolia_clear_index_if_existing', '__return_false' );
to class-algolia-cli.php
in an else statement, somewhere around line 126
.