Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-314

Using index by its name through helper cursor.hint()

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8, 3.0
    • Affects Version/s: 2.1.1
    • Component/s: None
    • Labels:

      Now for using index we can use helper cursor.hint(index). index should be an index as passed to create_index() (e.g. [('field', ASCENDING)]):

      collection.ensure_index(name="indexname", [("length", pymongo.ASCENDING)])
      cursor.hint([("length", pymongo.ASCENDING)])
      

      But it will be more flexible to get an opportunity to write

      collection.ensure_index(name="indexname", [("length", pymongo.ASCENDING)])
      cursor.hint("indexname")
      

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            uladzimir_mihura@epam.com Uladzimir Mihura
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: