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

Add section for index usage restrictions to $expr docs page

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • Server_Docs_20231030
    • 3.6 Core Server
    • Server
    • None
    • 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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              6 years, 14 weeks, 6 days ago