MongoEngine / MongoEngine/mongoengine

Indexes for embedded documents

Open
#518 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement
Dominant language
Python
Stars
4.3k
Forks
1.2k
Avg merge
4h 41m
Merged PRs (30d)
11

Description

Discuss:
Currently MongoEngine design requires explicitly indexes creation at main document. In the example bellow in order to index each Post comments type an index must be created as 'comments.type', the meta part from Comment Class is ignore.

Upgrade the existing logic to support an additional feature that creates indexes for each field based on the Embedded document meta:

class Comment(db.EmbeddedDocument):
    comment = db.StringField()
    type = db.IntField()
    author = db.ReferenceField(User,dbref=False) 
    meta = {'indexes': ['+author','type']}

class Post(db.Document):
    post = db.StringFiled()
    comments = db.ListField(db.EmbeddedDocumentField(Comment))

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are named. Start by tracing the existing index creation logic for embedded documents and how EmbeddedDocument meta indexes are read. Done means an embedded document's meta indexes are applied to the containing document's embedded fields, including the example's comments.type and comments.author indexes.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, python
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.