doctrine / mongodb-odm

The Official PHP MongoDB ORM/ODM
https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/latest/
MIT License
1.09k stars 502 forks source link

Support wildcard indexes #2371

Closed jseparovic1 closed 2 years ago

jseparovic1 commented 2 years ago

Feature Request

Q A
New Feature yes
RFC no
BC Break no

Summary

Mongodb supports adding wildcard Indexes but it is not possible to configure it via mongodb-odm mappings.

Using following mapping:

<indexes>
    <index name="field.$**">
        <key name="field_wildcard"/>
    </index>
</indexes>

Results in error Line 27:0: Element '{http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping}index', attribute 'name': 'tenants.$**.configured' is not a valid value of the atomic type 'xs:NMTOKEN'.

IonBazan commented 2 years ago

Thanks for your bug report @jseparovic1. Let me know if #2372 fixes the issue for you.

IonBazan commented 2 years ago

@jseparovic1 According to XSD schema, it is actually possible to create an index with wildcard keys - only the index name is currently limited to xs:NMTOKEN. If you don't mind renaming your index, you can always use:

<indexes>
    <index name="field_wildcard_1">
        <key name="field.$**"/>
    </index>
</indexes>

until 2.2.3 is released.