def index_create(index, body=None, hosts=None, profile=None, source=None):
    '''
    Create an index

    index
        Index name
    body
        Index definition, such as settings and mappings as defined in https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
    source
        URL to file specifying index definition. Cannot be used in combination with ``body``.

    CLI example::

        salt myminion elasticsearch.index_create testindex
        salt myminion elasticsearch.index_create testindex2 '{"settings" : {"index" : {"number_of_shards" : 3, "number_of_replicas" : 2}}}'
    '''
    es = _get_instance(hosts, profile)
    if source and body:
        message = 'Either body or source should be specified but not both.'
        raise SaltInvocationError(message)
    if source:
        body = __salt__['cp.get_file_str'](
                  source,
                  saltenv=__opts__.get('saltenv', 'base'))
    try:
        result = es.indices.create(index=index, body=body)
        return result.get('acknowledged', False) and result.get("shards_acknowledged", True)
    except elasticsearch.TransportError as e:
        if "index_already_exists_exception" == e.error:
            return True

        raise CommandExecutionError("Cannot create index {0}, server returned code {1} with message {2}".format(index, e.status_code, e.error))
def index_create ( index , body = None , hosts = None , profile = None , source = None ) : es = _get_instance ( hosts , profile ) if source and body : message = 'Either body or source should be specified but not both.' raise SaltInvocationError ( message ) if source : body = __salt__ [ 'cp.get_file_str' ] ( source , saltenv = __opts__ . get ( 'saltenv' , 'base' ) ) try : result = es . indices . create ( index = index , body = body ) return result . get ( 'acknowledged' , False ) and result . get ( "shards_acknowledged" , True ) except elasticsearch . TransportError as e : if "index_already_exists_exception" == e . error : return True raise CommandExecutionError ( "Cannot create index {0}, server returned code {1} with message {2}" . format ( index , e . status_code , e . error ) )
Create an index

    index
        Index name
    body
        Index definition, such as settings and mappings as defined in https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html
    source
        URL to file specifying index definition. Cannot be used in combination with ``body``.

    CLI example::

        salt myminion elasticsearch.index_create testindex
        salt myminion elasticsearch.index_create testindex2 '{"settings" : {"index" : {"number_of_shards" : 3, "number_of_replicas" : 2}}}'