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

Cannot use the document representing the index key for the hint() with count()

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: v1.3.15
    • Component/s: manual
    • Labels:
      None
    • Last comment by Customer:
      true
    • Actual Time:
      4

      Description

      MongoDB 2.6 supports the use of hint() with count(). However, due to SERVER-14799, the hint only works with the string name of the index and not a document representing the index key.

      Currently the example in the 2.6 docs uses the document representing the index key in the hint, which is not working now.

      http://docs.mongodb.org/manual/reference/method/cursor.count/#specify-the-index-to-use

      The following operation uses the index { status: 1 } to return a count of the documents in the orders collection with the field ord_dt greater than new Date('01/01/2012') and the status field is equal to "D":

      db.orders.find(
         { ord_dt: { $gt: new Date('01/01/2012') }, status: "D" }
      ).hint( { status: 1 } ).count()

      Suggest changing the above to:

      The following operation uses the index { status: 1 } (with index name "status_1") to return a count of the documents in the orders collection with the field ord_dt greater than new Date('01/01/2012') and the status field is equal to "D":

      db.orders.find(
         { ord_dt: { $gt: new Date('01/01/2012') }, status: "D" }
      ).hint( "status_1" ).count()

      Also, it would be nice to explicitly ask users to use the name of the index in the hint in 2.6. (or at least before SERVER-14799 is backported to 2.6)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kay.kim Kay Kim (Inactive)
              Reporter:
              linda.qin Linda Qin
              Participants:
              Last commenter:
              Jonathan Dahl Jonathan Dahl
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since reply:
                7 years, 8 weeks, 3 days ago
                Date of 1st Reply: