This patch adds the commands "search status" and "search reindex". Here is a possible use case:

drush -y search reindex
while [ $(drush search status --pipe | sed "s:/.*::") != 0 ] ; do
  drush cron
done

I've only actually tested this on D6 so far.

Comments

moshe weitzman’s picture

Status: Needs review » Needs work

Thats pretty neat. I think that drush reindex should optionally perform the reindexing in addition to the wipe. Also, don't we need an argument to specify which index needs to be wiped - node, user, etc. I haven't looked into search api in a while ... lets document the --pipe option for status.

john morahan’s picture

Status: Needs work » Needs review
StatusFileSize
new4.51 KB

Added an --immediate option for immediate reindexing, and a separate "search index" command to do this without wiping first. Also mentioned the --pipe option in help.

Search doesn't seem to provide an API for rebuilding a specific index, unless I've missed something. I guess we could module_invoke($module, 'search', 'reset') directly, if you really want this?

moshe weitzman’s picture

On D7 at least, I see search_reindex($sid = NULL, $type = NULL, $reindex = FALSE)

Oddly, I don't see apachesolr implementing that hook. Thats what I'd want to use. Oh well.

john morahan’s picture

AFAICT that doesn't wipe a whole index (which I assume is what you want) - it only wipes one specific item from an index, e.g. a single node. It also doesn't invoke any hooks while doing so, which is why apachesolr doesn't implement it. It only invokes hook_search('reset')/hook_search_reset() if you wipe the whole search index i.e. search_wipe()/search_reindex() with no parameters.

moshe weitzman’s picture

Status: Needs review » Fixed

Committed with minor changes. Added a drush_log() on remaining item count and added minor conditional when search_cron_limit is 0 (used by apachesolr).

Status: Fixed » Closed (fixed)

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

kcvata’s picture

Component: Code » PM (dl, en, up ...)

I am using the "search statuses" module. However, after searching for the #hashtagofinterest I do not want the extra step of clicking on the #hashtagofinterest to retrieve the all the statuses with that particular #hashtagofinterest.

I believe it is little code work. Any help with that will be greatly appreciated.

Regards,

Korkut Vata