Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-12838

Document that Expressions don't support array indexes in the dot notation

      Description

      I'm trying to find documents containing an array with equal values at positions 0 and 1. This query produces all documents in the collection:

      db.collection.find({
        $expr: {
          $eq: ["$arr.0", "$arr.1"]
        }
      })
      

      (see this MongoPlayground)

      Is it documented somewhere that Expressions don't support array index dot notation? They do support object dot notation field paths.

      More discussion in this SO Q&A, in which user Ashh claimed that `"You cannot use field names inside the expr"`, but I couldn't figure out if they were quoting some official docs, and the ensuing discussion ended up being rather confusing.

      Scope of changes

      • Investigate behavior of `$expr` with `$eq` and array index dot notation
      • Update documentation as appropriate

      Impact to Other Docs

      MVP (Work and Date)

      Resources (Scope or Design Docs, Invision, etc.)

            Assignee:
            Unassigned Unassigned
            Reporter:
            dandv Dan Dascalescu
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              1 year, 24 weeks, 3 days ago