2

I am maintaining a site that I did not build. It was discovered that some 300 nodes of type "custom" had incorrect url aliases. There are a total of 7961 nodes of type "custom" in the site at this moment.

$ drush sql-query "SELECT COUNT(nid) FROM node WHERE type LIKE 'custom';"

I have found the list of solr drush commands, and I see that solr-delete-index is able to remove a specific content type and then solr-mark-all could be used to indicate they should all be reindexed. My question is, how can I reindex only the 300 bad ones on this live site. I do have their nids in a separate csv file already, made from a custom sql query.

Just to be clear:

  • the site is live and important it stays that way
  • there is only a small portion of the content type that needs reindexed
  • I have all the permissions and access, no need to ask if I can get somewhere. Assume I can.
  • I have the means to identify the nodes to reindex and pipe them to various things and languages. I would even xargs a custom drush script if you have a means for doing this to a single node.
  • I have used "drush solr-mark-all node:custom_page" and then "drush solr-index" to process all 7961 nodes because it was available with the solr module. However, I am still interested in a better answer to this question. I will accept Clive's if there are no better ones this week. – DeveloperWeeks Dec 28 '15 at 18:45
1

In case you don't find a better way (doesn't look like there's an existing Drush command), here's a pretty simple solution cobbled together from various functions in the module:

$solr = apachesolr_get_solr();
$nids = array(1, 2, 3, 4, ...);
foreach ($nids as $nid) {
  $solr->deleteById(apachesolr_document_id($nid));
  db_update('apachesolr_search_node')
    ->condition('nid', $nid)
    ->fields(array('changed' => REQUEST_TIME, 'status' => 1))
    ->execute();
}
apachesolr_index_set_last_updated(REQUEST_TIME);

Untested, use with caution!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.