/* * Close connection. */ close() { this.client.close(); }
/* * Insert document into cluster. */ report(data) { const {client, index, type} = this; // Insert document into cluster. return Promise.fromNode(cb => { client.index({index, type, body: data}, cb); }); }
/* * Ping connection. */ ping() { const client = this.client; return Promise.fromNode(cb => { client.ping(cb); }) .then(success => { if (!success) { return Promise.reject({ status: 502, message: 'Could not reach the elasticsearch instance!', }); } }); }
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() }) })
async function testSearch () { const result = await client.search({ index, type, body: { query: { match: { 'Title': 'Hound' } } } }) console.log('testSearch', result) }
putTemplate(name, body) { this.client .indices .putTemplate({ name: name, body: body }); this.logElastic('info', `[TEMPLATE] created/updated [${name}]`); }
test.before('delete indexes in case they exist', async () => { const client = esFixtures.bootstrap().client; const arrayOfPromsies = indexes.map(async (index) => { return client.indices.delete({ index: index, ignore: [404] }); }); await Promise.all(arrayOfPromsies); });
async bulk(body) { const response = await this.client .bulk({ body: body }); return (response.items.length > 0); }
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() }) })
/* * Close connection. */ close() { this.client.close(); }
/* * Insert document into cluster. */ report(data) { const {client, index, type} = this; // Insert document into cluster. return Promise.fromNode(cb => { client.index({index, type, body: data}, cb); }); }
/* * Ping connection. */ ping() { const client = this.client; return Promise.fromNode(cb => { client.ping(cb); }) .then(success => { if (!success) { return Promise.reject({ status: 502, message: 'Could not reach the elasticsearch instance!', }); } }); }