$limit = 10; $continue = false; $cli->output($row['path']); do { $cmd = "{$php} extension/ezfind/bin/php/updatesearchindexsolr.php -s site_admin --topNodeID=${row['node_id']} --limit={$limit} --offset={$offset} 2>/dev/null"; $cli->output("\t".$offset); exec( $cmd, $out ); $lastLine = array_pop($out); if ( trim($lastLine) == $limit ) { $continue = true; $offset += $limit; } else { $continue = false; } } while ($continue); } $solr = new eZSolr(); $solr->commit(); $script->shutdown(0);
private function indexnode($nodeId) { $engine = new eZSolr(); $node = eZContentObjectTreeNode::fetch($nodeId); $object = eZContentObject::fetch($node->attribute('contentobject_id')); if ($object) { $result = $engine->addObject($object, false); $engine->commit(); } }
if ($object) { if ($needRemoveWithUpdate) { $searchEngine->removeObject($object, false); } $removeFromPendingActions = $searchEngine->addObject($object, false); } if ($removeFromPendingActions) { $db->query("DELETE FROM ezpending_actions WHERE action = 'index_object' AND param = '{$objectID}'"); } else { $cli->warning("\tFailed indexing object ID #{$objectID}, keeping it in the queue."); // Increase the offset to skip failing objects ++$offset; } $db->commit(); } $searchEngine->commit(); // clear object cache to conserve memory eZContentObject::clearCache(); } else { break; // No valid result from ezpending_actions } } $cli->output("Done"); $script->shutdown(); } catch (Exception $e) { $errCode = $e->getCode(); $errCode = $errCode != 0 ? $errCode : 1; // If an error has occured, script must terminate with a status other than 0 $script->shutdown($errCode, $e->getMessage()); }