[DOCS-14267] Clarify ambiguous $ positional operator behavior when matching multiple arrays Created: 04/Mar/21  Updated: 30/Oct/23  Resolved: 03/Feb/22

Status: Closed
Project: Documentation
Component/s: manual, Server
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Edwin Zhou Assignee: Kenneth Dyer
Resolution: Fixed Votes: 0
Labels: quick-win
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-53896 positional $ operator when there are ... Closed
is related to SERVER-54687 `$pull`ed index should not override q... Closed
Participants:
Days since reply: 2 years, 5 days ago
Epic Link: DOCSP-11702

 Description   

Description

The $ positional operator behaves ambiguously when there are multiple matching arrays. The work tracked on SERVER-18500 has not seen any progress, but we see this ambiguity causing issues with some users in SERVER-54687 and SERVER-53896.

https://docs.mongodb.com/manual/reference/operator/update/positional/

We should clarify we currently don't guarantee which array we get the position from when using the positional operator when there are multiple array matches.
Example:

doc = { a: [1, 2], z: [1, 2], b: [1, 2] }
db.coll.insert(doc);
db.coll.update({ a: 1, z: 2, b: 1 }, { $set: { "b.$": 3 } });

There is ambiguity around which index of the matched arrays (0 or 1) should we update b.
The current behavior returns:

{ "a" : [ 1, 2 ], "z" : [ 1, 2 ], "b" : [ 1, 3 ] }

where we update b using the index matched in z (index 1).

We may be able to guide users to consider $[<identifier>] if they need to make changes to an array based on a specified position. An example of favoring $[<identifier>] over $ can be found in my closing comment on SERVER-54687

Scope of changes

Impact to Other Docs

MVP (Work and Date)

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



 Comments   
Comment by Githook User [ 04/Feb/22 ]

Author:

{'name': 'Kenneth P. J. Dyer', 'email': '93145796+kennethdyer@users.noreply.github.com', 'username': 'kennethdyer'}

Message: DOCSP-14267- isLagged Update (#407)

  • DOCSP-14267 transfers text with expansion from old ticket
  • DOCSP-14267 transfers text with expansion from old ticket
  • DOCSP-14267 Updates per feedback
  • DOCSP-14267 Updates to example explanation
  • DOCSP-14267 vale cleanup
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 updates from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 refactor to include troubleshooting content
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
  • DOCSP-14267 Fixes from Jason feedback
Comment by Githook User [ 03/Feb/22 ]

Author:

{'name': 'Kenneth P. J. Dyer', 'email': '93145796+kennethdyer@users.noreply.github.com', 'username': 'kennethdyer'}

Message: DOCS-14267 Ambiguous Operator - Backport v4.0 (#500)
Branch: v4.0
https://github.com/10gen/docs-mongodb-internal/commit/970a9138b11c7d0162052996e6993ca95cf5d2e4

Comment by Githook User [ 03/Feb/22 ]

Author:

{'name': 'Kenneth P. J. Dyer', 'email': '93145796+kennethdyer@users.noreply.github.com', 'username': 'kennethdyer'}

Message: DOCS-14267 ambiguous dollar operator backport (#499)
Branch: v4.2
https://github.com/10gen/docs-mongodb-internal/commit/9fc9373ab0914ae60195b6abdc749dcbfbe85ca8

Comment by Githook User [ 03/Feb/22 ]

Author:

{'name': 'Kenneth P. J. Dyer', 'email': '93145796+kennethdyer@users.noreply.github.com', 'username': 'kennethdyer'}

Message: DOCS-14267 Ambiguous Positional Operator (#254) (#498)

  • Merge
  • Fixes spacing
  • Text refactor
  • DOCS-14267 Rework paragraphing, modified gerund to infinitive
  • DOCS-14267 Text adjustment per internal feedback

Co-authored-by: Kenneth P. J. Dyer <kennethpdyer@hecatia.local>

Co-authored-by: Kenneth P. J. Dyer <kennethpdyer@hecatia.local>
Branch: v4.4
https://github.com/10gen/docs-mongodb-internal/commit/93029e3e768e64aeb717cf39e1864feaf4ad5fc9

Comment by Githook User [ 03/Feb/22 ]

Author:

{'name': 'Kenneth P. J. Dyer', 'email': '93145796+kennethdyer@users.noreply.github.com', 'username': 'kennethdyer'}

Message: DOCS-14267 Ambiguous Positional Operator (#254) (#496)

  • Merge
  • Fixes spacing
  • Text refactor
  • DOCS-14267 Rework paragraphing, modified gerund to infinitive
  • DOCS-14267 Text adjustment per internal feedback

Co-authored-by: Kenneth P. J. Dyer <kennethpdyer@hecatia.local>

Co-authored-by: Kenneth P. J. Dyer <kennethpdyer@hecatia.local>
Branch: v5.0
https://github.com/10gen/docs-mongodb-internal/commit/81cff502e0093b38e86c45416fbda0458465c5f7

Comment by Githook User [ 03/Feb/22 ]

Author:

{'name': 'Kenneth P. J. Dyer', 'email': '93145796+kennethdyer@users.noreply.github.com', 'username': 'kennethdyer'}

Message: DOCS-14267 Ambiguous Positional Operator (#254) (#497)

  • Merge
  • Fixes spacing
  • Text refactor
  • DOCS-14267 Rework paragraphing, modified gerund to infinitive
  • DOCS-14267 Text adjustment per internal feedback

Co-authored-by: Kenneth P. J. Dyer <kennethpdyer@hecatia.local>

Co-authored-by: Kenneth P. J. Dyer <kennethpdyer@hecatia.local>
Branch: v5.2
https://github.com/10gen/docs-mongodb-internal/commit/a31ba075188c527f3731a75beb36cc011b2a976e

Comment by Githook User [ 28/Jan/22 ]

Author:

{'name': 'Kenneth P. J. Dyer', 'email': '93145796+kennethdyer@users.noreply.github.com', 'username': 'kennethdyer'}

Message: DOCS-14267 Ambiguous Positional Operator (#254)

  • Merge
  • Fixes spacing
  • Text refactor
  • DOCS-14267 Rework paragraphing, modified gerund to infinitive
  • DOCS-14267 Text adjustment per internal feedback

Co-authored-by: Kenneth P. J. Dyer <kennethpdyer@hecatia.local>
Branch: master
https://github.com/10gen/docs-mongodb-internal/commit/0b2591cd64a35f535bf54ad70f75f1e030e5e7b9

Generated at Thu Feb 08 08:09:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.