nodes: 0, module; 1, function_definition; 2, function_name:create_query_index; 3, parameters; 4, block; 5, identifier:self; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, dictionary_splat_pattern; 11, expression_statement; 12, if_statement; 13, expression_statement; 14, return_statement; 15, identifier:design_document_id; 16, None; 17, identifier:index_name; 18, None; 19, identifier:index_type; 20, string; 21, identifier:partitioned; 22, False; 23, identifier:kwargs; 24, comment:"""
          Creates either a JSON or a text query index in the remote database.
  
          :param str index_type: The type of the index to create.  Can
              be either 'text' or 'json'.  Defaults to 'json'.
          :param str design_document_id: Optional identifier of the design
              document in which the index will be created. If omitted the default
              is that each index will be created in its own design document.
              Indexes can be grouped into design documents for efficiency.
              However, a change to one index in a design document will invalidate
              all other indexes in the same document.
          :param str index_name: Optional name of the index. If omitted, a name
              will be generated automatically.
          :param list fields: A list of fields that should be indexed.  For JSON
              indexes, the fields parameter is mandatory and should follow the
              'sort syntax'.  For example ``fields=['name', {'age': 'desc'}]``
              will create an index on the 'name' field in ascending order and the
              'age' field in descending order.  For text indexes, the fields
              parameter is optional.  If it is included then each field element
              in the fields list must be a single element dictionary where the
              key is the field name and the value is the field type.  For example
              ``fields=[{'name': 'string'}, {'age': 'number'}]``.  Valid field
              types are ``'string'``, ``'number'``, and ``'boolean'``.
          :param dict default_field: Optional parameter that specifies how the
              ``$text`` operator can be used with the index.  Only valid when
              creating a text index.
          :param dict selector: Optional parameter that can be used to limit the
              index to a specific set of documents that match a query. It uses
              the same syntax used for selectors in queries.  Only valid when
              creating a text index.
  
          :returns: An Index object representing the index created in the
              remote database
          """; 25, comparison_operator:index_type == JSON_INDEX_TYPE; 26, block; 27, elif_clause; 28, else_clause; 29, call; 30, identifier:index; 31, string_content:json; 32, identifier:index_type; 33, identifier:JSON_INDEX_TYPE; 34, expression_statement; 35, comparison_operator:index_type == TEXT_INDEX_TYPE; 36, block; 37, block; 38, attribute; 39, argument_list; 40, assignment; 41, identifier:index_type; 42, identifier:TEXT_INDEX_TYPE; 43, expression_statement; 44, raise_statement; 45, identifier:index; 46, identifier:create; 47, identifier:index; 48, call; 49, assignment; 50, call; 51, identifier:Index; 52, argument_list; 53, identifier:index; 54, call; 55, identifier:CloudantArgumentError; 56, argument_list; 57, identifier:self; 58, identifier:design_document_id; 59, identifier:index_name; 60, keyword_argument; 61, dictionary_splat; 62, identifier:TextIndex; 63, argument_list; 64, integer:103; 65, identifier:index_type; 66, identifier:partitioned; 67, identifier:partitioned; 68, identifier:kwargs; 69, identifier:self; 70, identifier:design_document_id; 71, identifier:index_name; 72, keyword_argument; 73, dictionary_splat; 74, identifier:partitioned; 75, identifier:partitioned; 76, identifier:kwargs
code: def create_query_index(
              self,
              design_document_id=None,
              index_name=None,
              index_type='json',
              partitioned=False,
              **kwargs
      ):
          """
          Creates either a JSON or a text query index in the remote database.
  
          :param str index_type: The type of the index to create.  Can
              be either 'text' or 'json'.  Defaults to 'json'.
          :param str design_document_id: Optional identifier of the design
              document in which the index will be created. If omitted the default
              is that each index will be created in its own design document.
              Indexes can be grouped into design documents for efficiency.
              However, a change to one index in a design document will invalidate
              all other indexes in the same document.
          :param str index_name: Optional name of the index. If omitted, a name
              will be generated automatically.
          :param list fields: A list of fields that should be indexed.  For JSON
              indexes, the fields parameter is mandatory and should follow the
              'sort syntax'.  For example ``fields=['name', {'age': 'desc'}]``
              will create an index on the 'name' field in ascending order and the
              'age' field in descending order.  For text indexes, the fields
              parameter is optional.  If it is included then each field element
              in the fields list must be a single element dictionary where the
              key is the field name and the value is the field type.  For example
              ``fields=[{'name': 'string'}, {'age': 'number'}]``.  Valid field
              types are ``'string'``, ``'number'``, and ``'boolean'``.
          :param dict default_field: Optional parameter that specifies how the
              ``$text`` operator can be used with the index.  Only valid when
              creating a text index.
          :param dict selector: Optional parameter that can be used to limit the
              index to a specific set of documents that match a query. It uses
              the same syntax used for selectors in queries.  Only valid when
              creating a text index.
  
          :returns: An Index object representing the index created in the
              remote database
          """
          if index_type == JSON_INDEX_TYPE:
              index = Index(self, design_document_id, index_name,
                            partitioned=partitioned, **kwargs)
          elif index_type == TEXT_INDEX_TYPE:
              index = TextIndex(self, design_document_id, index_name,
                                partitioned=partitioned, **kwargs)
          else:
              raise CloudantArgumentError(103, index_type)
          index.create()
          return index