async getSettings(index) { const response = await this.client .indices .getSettings({ index: index, includeDefaults: true, human: true }); return response; }
after(async function() { await Model.deleteMany({}); await client.indices.delete({ index }); });
const addmappingToIndex = async function(indexName, mappingType, mapping){ console.log(mapping); return await esClient.indices.putMapping({ index: indexName, type: mappingType, body: mapping }); }
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); });
function testMapping() { return ESClient.indices .getMapping({ index: "imdb" }) .then(result => { console.log("|Test Mapping|"); console.log("-----------------------------------"); console.log("Response Body: "); console.log(JSON.stringify(result)); }) .catch(err => console.error(`Error connecting to the es client: ${err}`)); }
test.after.always('remove created indexes', async () => { const client = esFixtures.bootstrap().client; const arrayOfPromises = indexes.map((index) => { return client.indices.delete({ index: index, ignore: [404] }); }); await Promise.all(arrayOfPromises); });
/* ind = index */ function createIndex(ind) { return existsIndex(ind).then((resp) => { if(!resp) return client.indices.create({index: ind}) }) }
/* ind = index */ function deleteIndex(ind) { return client.indices.delete({index: ind}) }
putTemplate(name, body) { this.client .indices .putTemplate({ name: name, body: body }); this.logElastic('info', `[TEMPLATE] created/updated [${name}]`); }
async getAlias(alias) { return await this.client .indices .getAlias({ name: alias }); }
async putAlias(index, alias) { await this.client .indices .putAlias({ index: index, name: alias }); this.logElastic('info', `[ALIAS] successfully added alias [${alias}] to [${index}]!`); }
async delIndex(index) { await this.client .indices .delete({ index: index }); this.logElastic('info', `[DELETE] successfully deleted index [${index}]!`); }