[DOCS-10964] Add section for index usage restrictions to $expr docs page Created: 30/Oct/17  Updated: 30/Oct/23  Resolved: 02/Nov/17

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: 3.6 Core Server
Fix Version/s: Server_Docs_20231030

Type: Task Priority: Major - P3
Reporter: James Wahlin Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 6 years, 14 weeks, 6 days ago
Story Points: 1

 Description   

Regarding the following page:
https://docs.mongodb.com/master/reference/operator/query/expr

Please add a section that describes $expr index use limitations. When $expr is used within a query or aggregation $match stage, we will attempt to rewrite the aggregation expression to a match language expression. This rewrite when possible allows for participation on query planning and index selection. We support comparison expressions (outside of $cmp which has no match equivalent) and $in for rewrite.

We do not however support rewrite / index use for local document dotted field paths in $expr. The reason for this is dotted field paths in the Aggregation language are not evaluate in the same manner as in the match language. This prevents us from performing a rewrite without impacting correctness. As a workaround (which won't be possible for all $expr use cases) users can supplement the $expr statement with indexed match language statements to filter.

For $lookup users, we continue to support localField/foreignField syntax, which will use indexes in the same manner it does in 3.4.



 Comments   
Comment by James Wahlin [ 02/Nov/17 ]

I am closing this documentation request as the $expr cases we can index may be different than those listed here due to SERVER-31804. I will create a new ticket if there are changes needed once we addressed that ticket. Thanks!

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