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

Add example for $or case to the sorting with indexes tutorial

      RE:
      http://docs.mongodb.org/manual/tutorial/sort-results-with-indexes/#sort-and-index-prefix
      http://docs.mongodb.org/manual/reference/operator/query/or/#or-and-sort-operations

      It would be nice if there was an example of the effect of $or on sorted results. The second reference says indexes can be used to satisfy sort in the case of $or (presumably if all requirements are met) but doesn't really mention if there are any additional requirements.

      What if only one of the indexes for one of the $or branches satisfies the sort criteria?

      Since branches are evaluated independently they could potentially independently satisfy the sort too (a merge-sort at the top-level cannot be avoided), but I do not know the implemented behavior.

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            andrew.ryder@mongodb.com Andrew Ryder (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

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