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

We should clarify that range queries on non-array fields do not work with multi-key indexes

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      This page: http://docs.mongodb.org/master/core/multikey-index-bounds/

      It should mention the following limitation. If there is a compound multi-key index including a non-array field, then if this field is queried (and even if it's a leading field in the index and if queried alone with no array field) then MongoDB will not be able to intersect the bounds properly. And $elemMatch will not help because it is designed to work with array fields only.

      The only workaround is to create a non-multi key index on the non-array field and use that for the range queries.

      The situation is explained in detail in SERVER-6720.

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            dmitry.ryabtsev@mongodb.com Dmitry Ryabtsev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              6 years, 40 weeks, 4 days ago