Skip to content

Commit

Permalink
ability to use custom elasticsearch client in the elasticsearch stora…
Browse files Browse the repository at this point in the history
  • Loading branch information
evereq authored and rehia committed Jan 4, 2017
1 parent 0738166 commit 69e7b1b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
26 changes: 25 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,31 @@ example with elasticsearch:
log: 'warning', // optional
maxSearchResults: 10000 // optional
});


example with custom elasticsearch client (e.g. with AWS ElasticSearch client. Note ``` http-aws-es ``` package usage in this example):

var elasticsearch = require('elasticsearch');

var esClient = = new elasticsearch.Client({
hosts: 'SOMETHING.es.amazonaws.com',
connectionClass: require('http-aws-es'),
amazonES: {
region: 'us-east-1',
accessKey: 'REPLACE_AWS_accessKey',
secretKey: 'REPLACE_AWS_secretKey'
}
});

var es = require('eventstore')({
type: 'elasticsearch',
client: esClient,
indexName: 'eventstore',
eventsTypeName: 'events',
snapshotsTypeName: 'snapshots',
log: 'warning',
maxSearchResults: 10000
});

example with azuretable:

var es = require('eventstore')({
Expand Down
6 changes: 5 additions & 1 deletion lib/databases/elasticsearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ _.extend(Elastic.prototype, {

connect: function (callback) {
var options = this.options;
this.client = new elasticsearch.Client({host: options.host, log: options.log});
if (options.client) {
this.client = options.client;
} else {
this.client = new elasticsearch.Client({host: options.host, log: options.log});
}
this.emit('connect');
if (callback) callback(null);
},
Expand Down

0 comments on commit 69e7b1b

Please sign in to comment.