'Create one or more indexes on this collection.
>>> from pymongo import IndexModel, ASCENDING, DESCENDING
>>> index1 = IndexModel([("hello", DESCENDING),
...                      ("world", ASCENDING)], name="hello_world")
>>> index2 = IndexModel([("goodbye", DESCENDING)])
>>> db.test.create_indexes([index1, index2])
["hello_world", "goodbye_-1"]
:Parameters:
- `indexes`: A list of :class:`~pymongo.operations.IndexModel`
instances.
.. note:: `create_indexes` uses the `createIndexes`_ command
introduced in MongoDB **2.6** and cannot be used with earlier
versions.
.. note:: The :attr:`~pymongo.collection.Collection.write_concern` of
this collection is automatically applied to this operation when using
MongoDB >= 3.4.
.. versionchanged:: 3.4
Apply this collection\'s write concern automatically to this operation
when connected to MongoDB >= 3.4.
.. versionadded:: 3.0
.. _createIndexes: https://docs.mongodb.com/manual/reference/command/createIndexes/'

def create_indexes(self, indexes):

    if (not isinstance(indexes, list)):
        raise TypeError('indexes    must    be    a    list')
    names = []
    def gen_indexes():
        for index in indexes:
            if (not isinstance(index, IndexModel)):
                raise TypeError(('%r    is    not    an    instance    of    pymongo.operations.IndexModel' % (index,)))
            document = index.document
            names.append(document['name'])
            (yield document)
    cmd = SON([('createIndexes', self.name), ('indexes', list(gen_indexes()))])
    with self._socket_for_writes() as sock_info:
        self._command(sock_info, cmd, read_preference=ReadPreference.PRIMARY, codec_options=_UNICODE_REPLACE_CODEC_OPTIONS, write_concern=self.write_concern, parse_write_concern_error=True)
    return names
