title: How can I create an index with pymongo
body: <p>I want to enable text-search at a specific field in my Mongo DB. I want to implement this search in python (-> pymongo). When I follow the instructions given in the internet:</p>
  
  <pre><code>db.foo.ensure_index(('field_i_want_to_index', 'text'), name="search_index")
  </code></pre>
  
  <p>I get the following error message:</p>
  
  <pre><code>    Traceback (most recent call last):
      File "CVE_search.py", line 8, in &lt;module&gt;
      db.foo.ensure_index(('field_i_want_to_index', 'text'), name="search_index")
   File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 1599, in ensure_index
          return self.create_index(key_or_list, cache_for, **kwargs)
        File "/usr/local/lib/python2.7/dist-packages/pymongo/collection.py", line 1466, in create_index
          index_doc = helpers._index_document(keys)
        File "/usr/local/lib/python2.7/dist-packages/pymongo/helpers.py", line 100, in _index_document
              for (key, value) in index_list:
      ValueError: too many values to unpack
  </code></pre>
  
  <p>Is there a different/better way to create an index in pymongo? </p>