2dsphere indexes get re-created everytime
buffcode opened this issue · 1 comments
buffcode commented
Bug Report
Q | A |
---|---|
BC Break | no |
Version | 2.5.x |
Summary
Indexes of type 2dsphere
are always re-created.
Current behavior
Because the server-side options contain a 2dsphereIndexVersion
a mismatch is caused when comparing index options.
How to reproduce
/**
* @ODM\Document
* @ODM\Index(keys={"coordinatesWith2DIndex"="2d"})
* @ODM\Index(keys={"coordinatesWithSphereIndex"="2dsphere"})
*/
class GeoIndexDocument
{
/**
* @ODM\Id
*
* @var string|null
*/
public $id;
/** @ODM\Field(type="hash") */
public $coordinatesWith2DIndex;
/** @ODM\Field(type="hash") */
public $coordinatesWithSphereIndex;
}
For debugging purposes add the following code to \Doctrine\ODM\MongoDB\SchemaManager::updateDocumentIndexes, right before $collection->dropIndex(...):
dump('Dropping index ' . $mongoIndex['name'] . ' on ' . $documentName);
Run:
$ bin/console doctrine:mongodb:schema:update
Dropping index coordinates_2dsphere on GeoIndexDocument
Updated indexes for all classes
Updated validation for all classes
Expected behavior
Do not drop/re-create 2dsphere indexes