ElasticSearch.update()

Update (reindex) the document with the specified unique id.

If no document with the specified id exists, one will be created.

Usage

Hover over inputs/exits for more info.

var ElasticSearch = require('machinepack-elasticsearch');


// Update (reindex) the document with the specified unique id.

ElasticSearch.update({

hostname: 'localhost',

index: 'myindex',

id: 'lzmkDgMjTbGoacxLMsB_zA',

document: {},

port: 9200,

type: 'user',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Could not connect to ElasticSearch at the provided hostname and port, or all connections in the ES client pool are "dead".

couldNotConnect: function () {

 

},

// The specified index does not exist

noSuchIndex: function () {

 

},

// No document with the specified id and type exists in this index

documentNotFound: function () {

 

},

// Document with specified id and type did not exist, so it was created.

created: function (result) {

 

},

// OK.

success: function () {

 

},

});

Inputs

hostname required

The hostname of your ElasticSearch server

'localhost'
index required

The name of the index where the document is stored

'myindex'
id required

The unique id of the document to replace

'lzmkDgMjTbGoacxLMsB_zA'
document required

The new document (a dictionary) to replace the old one

port

The port your ElasticSearch server is running on

9200
type

The "type" of the document to update

'user'

Exits

error

An unexpected error occurred.

couldNotConnect

Could not connect to ElasticSearch at the provided hostname and port, or all connections in the ES client pool are "dead".

noSuchIndex

The specified index does not exist

documentNotFound

No document with the specified id and type exists in this index

created

Document with specified id and type did not exist, so it was created.

'lzmkDgMjTbGoacxLMsB_zA'
success

OK.