1

The scenario is to delete bulk documents from apache solr, without deleting the actual node from the database. I am aware that when the node is un-published it will be deleted from solr.

But as my node are very large containing 1000's of terms I don not want to use node-save to un-publish the node.

Is there any hook or function which un-publishes the node and deletes from solr by minimal load (definitely not node save) ?

UPDATE:

  • Drupal Version : 7.15
  • Modules: Apachesolr
0

1 Answer 1

1

I found the answer on exploring the apache solr module,

STEP 1

Select the nodes from the node table alone or by joining the apachesolr index entities table,

// Check for unpublished content that wasn't deleted from the index. $table = apachesolr_get_indexer_table('node'); // Select the nids from the node table $query = db_select($table, 'aien') ->fields('aien', array('entity_id')) ->condition('n.nid', 0); $query->leftJoin('node', 'n', 'n.nid = aien.entity_id'); $nodes = $query->execute()->fetchAllAssoc('nid'); 

STEP 2

Chunk it to some limit and call the apachesolr_index_nodeapi_mass_delete function

 $node_lists = array_chunk($nodes, '100', TRUE); foreach ($node_lists as $nodes) { watchdog('Apache Solr', 'On cron running apachesolr_nodeapi_mass_delete() on nids @nids', array('@nids' => implode(',', array_keys($nodes))), WATCHDOG_WARNING); if (!apachesolr_index_nodeapi_mass_delete($nodes, $table)) { // Solr query failed - so stop trying. break; } } 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.