Problem/Motivation

Running drush search-api:reset-tracker without arguments does not rebuild tracking information as its name would suggest, instead it triggers reindex.

Therefore it is not possible to create indexes on a site with pre-existing content via drush without clicking the rebuild tracking information link on the index status page first.

Proposed resolution

Rebuild tracker when command is run.

Comments

volkerk created an issue. See original summary.

volkerk’s picture

Status: Active » Needs review
StatusFileSize
new768 bytes

Status: Needs review » Needs work

The last submitted patch, 2: 3119335.patch, failed testing. View results

ivan616’s picture

Status: Needs work » Needs review

Hey volkerk,

I believe you might just misinterpret the names of functions.
In the comment above resetTracker command, we have this:

* Marks one or all indexes for reindexing without deleting existing data.

This is exactly what it does, with the help of
$index->reindex();

I have just set up the test environment locally to recreate the same scenario.
And with a combination of commands:

drush search-api:reset-tracker
drush sapi-i
> [notice] Successfully indexed 3 items.
> [notice] Message: Successfully indexed 3 items.

drush cr

I managed to re-create indexes and saw the changes in the content in an indexed view.

I hope this helps and cheers,
Ivan

volkerk’s picture

StatusFileSize
new18.18 KB

Thank you very much for your reply, I tried running the commands you suggested

drush search-api:reset-tracker
drush sapi-i

unfortunately this does not work for me. The index is not re-indexed. If I use the "Rebuild tracking information" link on the status page of the index, re-indexing works using drush sapi-i.

This is how the status page looks initially:

drunken monkey’s picture

Status: Needs review » Needs work

Thanks for reporting this issue!
Ivan616 is right, though: You’re misinterpreting the command, what it does is clearly documented.
I am fully prepared to admit that the name is misleading, since we later added the “rebuild tracker” functionality you’re looking for, but the command is still correct and definitely cannot just be changed at this point.

Instead, I’m happy to add a new search-api-rebuild-tracker command (or similar) that does what you’re asking for. You’re right: this functionality doesn’t seem available yet via Drush.

chr.fritsch’s picture

Status: Needs work » Needs review
StatusFileSize
new2.31 KB

Here is the new drush command

chr.fritsch’s picture

Title: Reset-tracker drush command functionality is misleading » Add rebuild-tracker drush command
drunken monkey’s picture

StatusFileSize
new2.2 KB
new2.27 KB

Thanks for the patch, looks pretty good!
A few minor nitpicks fixed in the attached revision, please test/review!

Also, though, should we maybe add a confirmation to the command? I.e., user has to enter y before we actually proceed?
Should maybe have done this for all the potentially (very) disruptive commands.

drunken monkey’s picture

Status: Needs review » Fixed

Committed, and just created #3135187: Add confirmation for disruptive Drush commands? as a follow-up.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.