Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ES 6 - error occurred while creating index #9

Closed
DavidFlamini opened this issue Mar 6, 2018 · 1 comment
Closed

ES 6 - error occurred while creating index #9

DavidFlamini opened this issue Mar 6, 2018 · 1 comment

Comments

@DavidFlamini
Copy link

DavidFlamini commented Mar 6, 2018

Hi, just leaving a quick note here, I upgraded my cluster to ES 6.2.2 yesterday and found out that the index creation function was failing to create the index with "error unknown", after a quick review of the code and ES output I fixed it by changing the content type on the http header to 'application/json'. I didn't have the time to confirm if there are any side-effects but the data seems to be flowing to ES just fine.

Here's the http function for reference.

# /p2es/es.py
def http(CONFIG, url, method="GET", data=None):
    auth = None
    if CONFIG['ES_AuthType'] != 'none':
        if CONFIG['ES_AuthType'] == 'basic':
            auth = HTTPBasicAuth(CONFIG['ES_UserName'], CONFIG['ES_Password'])
        elif CONFIG['ES_AuthType'] == 'digest':
            auth = HTTPDigestAuth(CONFIG['ES_UserName'], CONFIG['ES_Password'])
        else:
            raise P2ESError(
                'Unexpected authentication type: {}'.format(CONFIG['ES_AuthType'])
            )

    headers = {'Content-Type': 'application/json'} # <<<<<<<

    if method == "GET":
        return requests.get(url, auth=auth, headers=headers)
    elif method == "POST":
        return requests.post(url, auth=auth, data=data, headers=headers)
    elif method == "PUT":
        return requests.put(url, auth=auth, data=data, headers=headers)
    elif method == "HEAD":
        return requests.head(url, auth=auth, headers=headers)
    else:
        raise Exception("Method unknown: {}".format(method))
@pierky pierky closed this as completed in a78aace Mar 9, 2018
@pierky
Copy link
Owner

pierky commented Mar 10, 2018

Hello @DavidFlamini, thanks for reporting this.
I fixed it in master.

I'm also adding some Docker based tests on TravisCI ("tests" branch currently); unfortunately it seems that ES staff don't want to support the latesttag on their Docker images (elastic/elasticsearch-docker/issues/84), otherwise it would have been easier to automate this kind of testing and to get a notification as soon as things break in case of new release.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants