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

Document new restrictions on index key patterns in 3.4 release notes

    • Type: Icon: Task Task
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 3.4.0
    • Affects Version/s: None
    • Component/s: Server
    • Labels:
    • 1

      The values in the index key pattern are restricted to

      • numbers > 0 (ascending)
      • numbers < 0 (descending)
      • strings (special index types)

      Some specific values that may be of interest for which an error will now be returned:

      • 0
      • NaN
      • undefined and null
      • true and false
      • MinKey and MaxKey
      > db.mycoll.createIndex({a: 0})
      {
        "ok" : 0,
        "errmsg" : "bad index key pattern { a: 0.0 }: Values in the index key pattern cannot be 0.",
        "code" : 67
      }
      > db.mycoll.createIndex({a: NaN})
      {
        "ok" : 0,
        "errmsg" : "bad index key pattern { a: nan.0 }: Values in the index key pattern cannot be NaN.",
        "code" : 67
      }
      > db.mycoll.createIndex({a: true})
      {
        "ok" : 0,
        "errmsg" : "bad index key pattern { a: true }: Values in index key pattern cannot be of type Bool. Only numbers > 0, numbers < 0, and strings are allowed.",
        "code" : 67
      }
      

            Assignee:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:
              7 years, 22 weeks, 6 days ago