Exemple #1
0
def get_mapping(connection, type, es_version=DEFAULT_VERSION):
    if versions.mapping_url_0x(es_version):
        url = elasticsearch_url(connection, type, endpoint="_mapping")
        resp = _do_get(url, connection)
        return resp
    else:
        url = elasticsearch_url(connection, "_mapping", type)
        resp = _do_get(url, connection)
        return resp
Exemple #2
0
def get_mapping(connection, type, es_version=DEFAULT_VERSION):
    if versions.mapping_url_0x(es_version):
        url = elasticsearch_url(connection, type, endpoint="_mapping")
        resp = _do_get(url, connection)
        return resp
    else:
        url = elasticsearch_url(connection, "_mapping", type)
        resp = _do_get(url, connection)
        return resp
Exemple #3
0
def put_mapping(connection, type=None, mapping=None, make_index=True, es_version=DEFAULT_VERSION):
    if mapping is None:
        raise ESWireException("cannot put empty mapping")
    
    if not index_exists(connection):
        if make_index:
            create_index(connection, es_version=es_version)
        else:
            raise ESWireException("index '" + str(connection.index) + "' does not exist")

    if versions.mapping_url_0x(es_version):
        url = elasticsearch_url(connection, type, "_mapping")
        r = _do_put(url, connection, json.dumps(mapping))
        return r
    else:
        url = elasticsearch_url(connection, "_mapping", type)
        r = _do_put(url, connection, json.dumps(mapping))
        return r
Exemple #4
0
def put_mapping(connection,
                type=None,
                mapping=None,
                make_index=True,
                es_version=DEFAULT_VERSION):
    if mapping is None:
        raise ESWireException("cannot put empty mapping")

    if not index_exists(connection):
        if make_index:
            create_index(connection, es_version=es_version)
        else:
            raise ESWireException("index '" + str(connection.index) +
                                  "' does not exist")

    if versions.mapping_url_0x(es_version):
        url = elasticsearch_url(connection, type, "_mapping")
        r = _do_put(url, connection, json.dumps(mapping))
        return r
    else:
        url = elasticsearch_url(connection, "_mapping", type)
        r = _do_put(url, connection, json.dumps(mapping))
        return r