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

Improve documentation for Index Prefix

      Description

      The documentation for index prefixes https://docs.mongodb.com/manual/core/index-compound/#prefixes never calls out the fact that the following index 

       

      {a: 1, b: 1, c: 1}

       

      will support the queries

       

      db.docs.find({b: "foo", c: "bar", a: "baz"})
      db.docs.find({b: "foo", a: "bar"})
      

       

      and so on. We should point out that the query order in this case doesn't matter itself as long as either a subset of the prefix or the entire compound index is used.

       

      Scope of changes

      • Update linked section to note that for the query portion of the find (and possibly match?), the order of fields listed does not matter. If the fields specified in the query match a subset of the prefix or the entire compound index, then the query can use the index.
      • Should be explicit here that without a : bar, neither of these can work as noted in the compound index section
      • Check that this is true for $match, or if there are other caveats.

            Assignee:
            ravind.kumar Ravind Kumar (Inactive)
            Reporter:
            nathan.leniz@mongodb.com Nathan Leniz
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

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