// delete and recreate an index async recreateIndex(name, indexConfig) { try { await this.client.indices.delete({ index: name }) } catch (err) { // catch in case the index doesn't already exist } await this.client.indices.create({ index: name, body: indexConfig, }) }
/* ind = index */ function createIndex(ind) { return existsIndex(ind).then((resp) => { if(!resp) return client.indices.create({index: ind}) }) }
client.indices.create({ index: 'world', timeout: "5m" }, function(err, resp, status) { if (err) { console.log(err); } else { console.log("created elasticsearch", resp); mapping.putMapping(); } });
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 }); });
client.indices.exists({ index: esParams.index }) .then((isExists) => { if (isExists) { return client.indices.delete({ index: esParams.index }); } return null; }) .then(() => client.indices.create({ index: esParams.index, body })) .then(() => { console.log('All done!'); }) .catch((err) => { console.log(err); }) ;
client.indices.exists({ index: indexName }).then(function (exists) { if (!exists) { logger.debug('Creating index %s ...', indexName) return client.indices.create({ index: indexName }).then(function (r) { logger.info('Index %s created:', indexName, r) return Promise.resolve(r) }) } else { logger.debug('Index %s exists', indexName) return Promise.resolve() } }).catch(function (err) { logger.error('Unable to create index index %s ...', indexName, err) return Promise.reject(err) })
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]); });
return this.client.indices.create({ index: this.index, body: data
const createIndex = async function(indexName){ return await esClient.indices.create({ index: indexName }); }
client.indices.delete({index: 'address'}, ( err, resp, status ) => { client.indices.create({ index: 'address' }, ( err, resp, status ) => { if (err) { console.log(err.message); } else { console.log("Successfully created address index"); } }); });
test('should re-create existent index', async (t) => { const loader = esFixtures.bootstrap('create_index', type); await loader.client.indices.create({ index: 'create_index' }); const data = { mappings: { my_type_old: { properties: { name: { type: 'string' } } } } }; await loader.createIndex(data, { force: true }); t.notThrows(loader.client.indices.get({ index: 'create_index' })); });
var createIndex = function (indexName) { client.indices.create({index: indexName}, function(err, resp){ if (err) { console.log(err); return; } if (resp) { console.log(indexName + ' created'); addMapping(indexName, 'meta'); } else { console.log('Creation of ' + indexName + ' failed.'); process.exit(0); } }); }
function createRelationIndex() { client.indices.create({ index: "relation", body: { "mappings": { "doc": { "properties": { "IPs": { "type": "ip" } } } } } }, function (err, resp, status) { if (err) { console.log(err); } else { console.log("create", resp); } }); }
function createIPIndex() { client.indices.create({ index: "ip", body: {
function createTorrentIndex() { client.indices.create({ index: 'torrent', body: {