Skip to content

snapshot.create is not working #170

@jettro

Description

@jettro

To recreate this problem I have a node.js program. This is the code:

var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
    host: 'localhost:9200',
    log: 'trace',
    apiVersion: '1.4'
});

var newRepo = {
    "repository":"gridshore-repo",
    "snapshot":"test-2",
    "body": {
        "indices":"gridshore-*"
    }
};

client.snapshot.create(newRepo).then(function(data) {
    console.log(data);
});

And this is the output:

/usr/local/bin/node index.js
Elasticsearch INFO: 2014-12-12T09:33:55Z
  Adding connection to http://localhost:9200/

Elasticsearch DEBUG: 2014-12-12T09:33:55Z
  starting request { method: 'POST',
    path: '/_snapshot/gridshore-repo/test-2',
    body: { indices: 'gridshore-*' },
    query: {} }


Elasticsearch TRACE: 2014-12-12T09:33:55Z
  -> POST http://localhost:9200/_snapshot/gridshore-repo/test-2
  {
    "indices": "gridshore-*"
  }
  <- 400
  {
    "error": "InvalidIndexNameException[[_snapshot] Invalid index name [_snapshot], must not start with \u0027_\u0027]",
    "status": 400
  }

Elasticsearch DEBUG: 2014-12-12T09:33:55Z
  Request complete

Possibly unhandled Error: InvalidIndexNameException[[_snapshot] Invalid index name [_snapshot], must not start with '_']
    at respond (/Users/jettrocoenradie/sources/temp/elastictry/node_modules/elasticsearch/src/lib/transport.js:235:15)
    at checkRespForFailure (/Users/jettrocoenradie/sources/temp/elastictry/node_modules/elasticsearch/src/lib/transport.js:203:7)
    at HttpConnector.<anonymous> (/Users/jettrocoenradie/sources/temp/elastictry/node_modules/elasticsearch/src/lib/connectors/http.js:148:7)
    at IncomingMessage.bound (/Users/jettrocoenradie/sources/temp/elastictry/node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:943:16
    at process._tickCallback (node.js:419:13)

Now the problem is easy to be solved by changing the apis 1_4.js for example.
api.snapshot.prototype.create

change the method from POST into PUT and you are done.

If you want me to I can create a pull request, but the changes are so trivial that a pull request might be more work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions