Skip to content

Support subkey index for Parse Schema indexes #7711

Open

Description

@Moumouls

New Feature / Enhancement Checklist

Current Limitation

Parse Server do not support via Parse Schema the subkey index

Feature / Enhancement Description

Allow subkey index at parse index validation

Example Use Case

{indexes: { 'anArrayField.aKeyIntoAnElement': 1} }
Mongo example: https://docs.mongodb.com/manual/core/index-multikey/

Alternatives / Workarounds

Use the mongo client directly

3rd Party References

Mongo example: https://docs.mongodb.com/manual/core/index-multikey/

It seems that postgres support the feature but not sure if it will work: https://stackoverflow.com/questions/17807030/how-to-create-index-on-json-field-in-postgres

Activity

  1. parse-github-assistant commented on Nov 19, 2021

    @parse-github-assistant

    Thanks for opening this issue!

    • 🎉 We are excited about your ideas for improvement!
  2. added
    type:feature
    on Nov 19, 2021
  3. changed the title [-]Support subkey index from Parse Schema indexe (like: "anArrayField.aKeyIntoAnElement")[/-] [+]Support subkey index from Parse Schema indexes (like: "anArrayField.aKeyIntoAnElement")[/+] on Nov 19, 2021
  4. changed the title [-]Support subkey index from Parse Schema indexes (like: "anArrayField.aKeyIntoAnElement")[/-] [+]Support subkey index for Parse Schema indexes[/+] on Nov 19, 2021
  5. cerasonileonardo commented on Nov 9, 2026

    @cerasonileonardo

    We need this too, together with the wildcard variant on the same kind of field, and would like to contribute it.

    Use case. We run Parse Server on MongoDB with Defined Schemas (strict: true, keepUnknownIndexes not set). At each server start the migration deletes every index that is not declared in the definitions, so the indexes we need must be declared. A class stores a group of dates in an Object field date, and queries filter and sort on single keys of it per tenant:

    indexes: {
      org_date_funeral: { _p_org_pointer: 1, 'date.funeral': 1 },
      org_date_wildcard: { _p_org_pointer: 1, 'date.$**': 1 }, // compound wildcard, MongoDB 7.0+
    }

    The schema endpoint rejects both with Field date.funeral does not exist, cannot add index., because the index field validation only knows top-level fields (and the _p_ prefix). disableIndexFieldValidation accepts them, but it turns off the check for every index.

    Proposal. In MongoStorageAdapter.setIndexesWithSchemaFormat, also accept as an index key:

    • a key of an Object or Array field in dot notation: field.key, field.key.nestedKey (this also covers the multikey example in this issue, anArrayField.aKeyIntoAnElement);
    • a wildcard on all the keys of such a field: field.$** (also field.key.$**).

    The first segment must be a declared field of type Object or Array. The following segments must be non-empty and must not start with $, except a final $**. Everything else is still rejected with the current error. Nothing else changes: these keys are already stored in _SCHEMA and read back by updateSchemaWithIndexes as they are (_auth_data_<provider>.id works the same way). Postgres keeps rejecting them, since it would need expression indexes on jsonb.

    PR: #10876

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions