Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Create or Review Drush command : search-api-mark-all index (reindex, but reindex enforces also a start of the indexing)
Comment | File | Size | Author |
---|---|---|---|
#21 | 2230951-21--drush_reindex.patch | 11.06 KB | drunken monkey |
Comments
Comment #1
drunken monkeyComment #2
m1r1k CreditAttribution: m1r1k commentedComment #3
m1r1k CreditAttribution: m1r1k commentedComment #4
drunken monkeyThanks for the patch!
However, I'm really not sure how this is at all different from
search-api-reindex
– except that it doesn't invoke the hook, but that can hardly be the whole point?I think we should close this as "won't fix" – or does this really have a purpose?
Comment #5
m1r1k CreditAttribution: m1r1k commentedIn apachesolr and in native drupal search afaik it was introduced to support huge indexes on weak servers, to split big reindex for separate iterations.
Comment #6
Nick_vhYes, I would like to get this in, it is a very useful command to reindex everything without deleting everything. Reindex is reindexing everything on the spot, and that might not be intended if the indexing is running during cron or other ways to index your data.
Comment #7
drunken monkeyPlease look at the
drush.inc
file and the patch: what you describe is exactly whatsearch-api-reindex
does. It doesn't index any items (not even when "Index items immediately" is enabled), just marks all of them for indexing again. And this is whatsearch-api-mark-all
does, too, just without calling the proper hook.So, while it might have made sense in D7, it doesn't seem to have any use anymore in D8.
Comment #8
m1r1k CreditAttribution: m1r1k commentedHm, then may be problem is with 'search-api-reindex' method, because semantically it means immediate clear the index and reindex from scratch. So then may be just rename it to mark-all and that's it? :)
Comment #9
drunken monkeyClearing the index is something different again, when you reindex the old data still stays in the index (until it is gradually overwritten by the newly indexed data).
But you're right, this was always a bit confusing, probably. However, "mark all" is also not really descriptive by itself – mark in what way? So
search-api-mark-all-items-for-reindexing
would be the really clear name here, but that's of course too verbose again. But maybe we can do a quick poll somewhere, and if most users agree that the current name is too confusing go with something likesearch-api-queue-reindexing
. If the alias stays the same, hopefully it won't break that much (or cause that much confusion). Or, we could even set the old name as a second alias.Comment #10
Nick_vhI'm also more in favor of search-api-mark-all. Having anything related to reindex or index suggest an action that would index things. Which is not the case here. In Search API we have trackers that mark these things so we could also do:
search-api-retrack-all
search-api-reset-tracker
search-api-mark-all
search-api-mark-all-for-indexing
In pure technical correctness, I like the search-api-reset-tracker, as that effectively resets the tracker information and it would reindex everything. It's not something you should do often and should come with some warnings. I also believe it should come with certain options so that it could reset an individual item for the tracker but also complete entity types etc if you want to reindex all those.
Comment #11
drunken monkeyOK, then let's go with
search-api-reset-tracker
, add the old name as an alias, and maybe add options for marking only a single item or datasource, too (if easily possible).And yes, this should also have a confirmation step, like we have in the admin UI.
Comment #12
drunken monkeyBut since I don't think that any of the other commands have a confirmation step either, maybe that should be a separate issue, "Add confirmation steps to Drush commands".
Comment #13
m1r1k CreditAttribution: m1r1k commentedComment #14
Nick_vhmark-all aliases should probably not be there anymore
Comment #15
Nick_vhComment #16
drunken monkeyThanks for the new patch!
That has a bit of a larger scope, but I guess that's OK.
A few problems, though:
As Nick says, this should include the old
search-api-reindex
,mark-all-all-for-indexing
is definitely unnecessary here.Including
search-api-mark-all
probably makes sense, though. And maybe the alias of that in D7, too? That way, all old scripts will still work, even though the two commands now do the same.Those should be removed.
Is that correct? It seems the index is still passed as an argument, not an option?
No. This should still use
$index->reindex()
.Comment #17
m1r1k CreditAttribution: m1r1k commentedComment #18
drunken monkeyThanks, looks better already. However, still two problems (one smaller one larger):
I wondered about that myself, but I don't think we should invoke the hook when we're not doing a complete re-indexing.
If we really want to, we should have an extra argument for the hook to pass the affected datasources. But at the moment, I'd just skip this hook.
That won't work, will it?
$index_ids
will contain already loaded entities, but later in the function you pass this again tosearch_api_drush_get_indexes()
– and it will break.Same for the other places you changed that. Please make sure to properly handle both cases (index ID passed or not) with your code.
Comment #19
Manjit.SinghComment #20
Manjit.SinghComment #21
drunken monkeyBetter, thanks!
However, this still had some problems. How about this patch? Could someone please try out whether all commands now work as expected? (A review of the patch would also be appreciated, of course.)
Comment #22
drunken monkeyComment #24
drunken monkeyI'm committing this now, we can just see whether someone complains about things being broken.