Closed malcyL closed 3 months ago
Calling the ensureIndex method on IndexUtils does not correctly create indexes if the reindex flag is set to true.
Looking at this line of code: https://github.com/talis/tripod-php/blob/master/src/mongo/util/IndexUtils.class.php#L78
// Index views foreach($config->getViewSpecifications($storeName) as $viewId=>$spec) { $collection = Config::getInstance()->getCollectionForView($storeName, $viewId); if($collection) { $indexes = array(array("_id.type"=>1)); if(isset($spec['ensureIndexes'])) { $indexes = array_merge($indexes, $spec['ensureIndexes']); } if ($reindex) { $collection->deleteIndexes(); } foreach($indexes as $index) { $collection->ensureIndex( $index, array( "background"=>$background ) ); } } }
I think what is happening is that each index is created correctly, but but before it is added, a call is made to $collection->deleteIndexes(). This deletes all the indexes created in previous iterations of the loop.
Calling the ensureIndex method on IndexUtils does not correctly create indexes if the reindex flag is set to true.
Looking at this line of code: https://github.com/talis/tripod-php/blob/master/src/mongo/util/IndexUtils.class.php#L78
I think what is happening is that each index is created correctly, but but before it is added, a call is made to $collection->deleteIndexes(). This deletes all the indexes created in previous iterations of the loop.