test('client.search with callback', function userLandCode (t) { resetAgent(done(t, 'POST', '/_search', '{"q":"pants"}')) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) var query = { q: 'pants' } client.search(query, function (err) { t.error(err) agent.endTransaction() agent.flush() }) })
constructor(opts) { if (!(this instanceof ElasticSearch)) return new ElasticSearch(opts) this.client = new elasticsearch.Client(opts.connection); this.batchSizeDHT = opts.batchSizeDHT; this.batchSizeTorrent = opts.batchSizeTorrent this.recordInfohashQueue = []; this.recordTorrentQueue = []; this.recordIPQueue = []; this.recordRelationQueue = []; }
constructor(elasticOpts, mappings, bulkSize) { this.esClient = new elasticsearch.Client(elasticOpts); this.mappings = mappings; this.bulkSize = bulkSize; this.bulkOp = []; this.interval = null; }
constructor(config) { super(config); this.error = new Error(`Elasticsearch connection to ${this.config.url} failed.`); this.client = new elasticsearch.Client({ host: this.config.url, }); }
it ('should instantiate the Elasticsearch check class properly', async () => { const { Testee, elasticsearch } = makeMocks(); const options = { url: 'es://9200', }; const testeeInstance = new Testee(options); // uncomment following when https://github.com/facebook/jest/issues/2549 is solved. // expect(testeeInstance).toBeInstanceOf(Check); expect(testeeInstance.client).toBeInstanceOf(elasticsearch.Client); expect(testeeInstance.client.options).toBeDefined(); expect(testeeInstance.client.options.host).toBe(options.url); return expect(Testee.type).toBe('elasticsearch'); });
const initialise = async (reset) => { const config = process.env.ESCONFIG || 'http://localhost:9200' db = new elasticsearch.Client({ hosts: [config] }) }
test('client.msearch with callback', function userLandCode (t) { var body = [ {}, { query: { query_string: { query: 'pants' } } } ] var statement = body.map(JSON.stringify).join('\n') resetAgent(done(t, 'POST', '/_msearch', statement)) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) client.msearch({ body }, function (err) { t.error(err) agent.endTransaction() agent.flush() }) })
test('client.searchTemplate with callback', function userLandCode (t) { var body = { source: { query: { query_string: { query: '{{q}}' } } }, params: { q: 'pants' } } resetAgent(done(t, 'POST', '/_search/template', JSON.stringify(body))) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) client.searchTemplate({ body }, function (err) { t.error(err) agent.endTransaction() agent.flush() }) })
test('client.search with abort', function userLandCode (t) { resetAgent(3, done(t, 'POST', '/_search', '{"q":"pants"}', true)) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) var query = { q: 'pants' } var req = client.search(query) setImmediate(() => { req.abort() agent.endTransaction() agent.flush() }) })
test('client.ping with promise', function userLandCode (t) { resetAgent(done(t, 'HEAD', '/')) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) client.ping().then(function () { agent.endTransaction() agent.flush() }, function (err) { t.error(err) }) })
var client = new elasticsearch.Client({ host: host })
test('client.ping with callback', function userLandCode (t) { resetAgent(done(t, 'HEAD', '/')) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) client.ping(function (err) { t.error(err) agent.endTransaction() agent.flush() }) })
test('client.count with callback', function userLandCode (t) { resetAgent(done(t, 'POST', '/_count')) agent.startTransaction('foo') var client = new elasticsearch.Client({ host: host }) client.count(function (err) { t.error(err) agent.endTransaction() agent.flush() }) })
constructor({ host, user, password, logLevel }) { const conf = { host: host || `http://localhost:9200`, log: logLevel || `info`, } if (password) { // Use authentication const username = user || `elastic` conf.httpAuth = `${username}:${password}` } this.client = new elasticsearch.Client(conf) }
/** * Create instance * Possible config can be checked here: * https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/configuration.html * @param {string} index - index by default used in the operations * @param {string} type - type by default used in the operations * @param {Object} [config] - config object */ constructor (index, type, config) { this.client = new elasticsearch.Client(config); this.index = index; this.type = type; }