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}`)); }
before(async function() { // Create the ES index. const body = { mappings: { [type]: { properties: { name: { type: 'keyword' } } } }, }; await client.indices.create({ index, body }); const mappings = await client.indices.getMapping({ index, type }); // Create the documents in MongoDB via Mongoose. docs = await createDocuments(); // Index the documents in ES. await indexDocuments(docs); await client.indices.refresh({ index }); });
test('should add mapping', async (t) => { const index = 'mapping_index'; const loader = esFixtures.bootstrap(index, type); await loader.client.indices.create({ index: index }); const data = { properties: { name: { type: 'string' } } }; await loader.addMapping(data); const mappingRes = await loader.client.indices.getMapping({ index: index, type: type }); t.truthy(mappingRes[index].mappings[type]); });