def registerType( self, index, mapping ): """ It register the type and index, if does not exists :param str index name of the index :param dict mapping mapping used to create the index. """ all_index = "%s-*" % index if self.exists( all_index ): indexes = self.getIndexes() if indexes: actualindexName = generateFullIndexName( index ) if self.exists( actualindexName ): self.log.info( "The index is exists:", actualindexName ) else: result = self.createIndex( index, mapping ) if not result['OK']: self.log.error( result['Message'] ) return result self.log.info( "The index is created", actualindexName ) else: # in that case no index exists result = self.createIndex( index, mapping ) if not result['OK']: self.log.error( result['Message'] ) else: return result
def registerType(self, index, mapping, period=None): """ It register the type and index, if does not exists :param str index: name of the index :param dict mapping: mapping used to create the index. :param str period: We can specify, which kind of indexes will be created. Currently only daily and monthly indexes are supported. """ all_index = "%s-*" % index if self.exists(all_index): indexes = self.getIndexes() if indexes: actualindexName = generateFullIndexName(index, period) if self.exists(actualindexName): self.log.info("The index is exists:", actualindexName) else: result = self.createIndex(index, mapping, period) if not result['OK']: self.log.error(result['Message']) return result self.log.info("The index is created", actualindexName) else: # in that case no index exists result = self.createIndex(index, mapping, period) if not result['OK']: self.log.error(result['Message']) else: return result
def registerType(self, index, mapping, period=None): """ It register the type and index, if does not exists :param str index: name of the index :param dict mapping: mapping used to create the index. :param str period: We can specify, which kind of indexes will be created. Currently only daily and monthly indexes are supported. """ all_index = "%s-*" % index if self.exists(all_index): indexes = self.getIndexes() if indexes: actualindexName = generateFullIndexName(index, period) if self.exists(actualindexName): self.log.info("The index is exists:", actualindexName) else: result = self.createIndex(index, mapping, period) if not result['OK']: self.log.error(result['Message']) return result self.log.info("The index is created", actualindexName) else: # in that case no index exists result = self.createIndex(index, mapping, period) if not result['OK']: self.log.error(result['Message']) else: return result
def setUp(self): self.elasticSearchDB = ElasticSearchDB(host=elHost, port=elPort, useSSL=False) result = generateFullIndexName('integrationtest') self.assertTrue(len(result) > len('integrationtest')) self.index_name = result result = self.elasticSearchDB.index(self.index_name, 'test', {"Color": "red", "quantity": 1, "Product": "a", "timestamp": 1458226213}) self.assertTrue(result['OK'])
def test_generateFullIndexName2(self): indexName = 'test' month = datetime.datetime.today().strftime("%Y-%m") expected = "%s-%s" % (indexName, month) result = generateFullIndexName(indexName, 'month') self.assertEqual(result, expected)
def test_generateFullIndexName(self): indexName = 'test' today = datetime.datetime.today().strftime("%Y-%m-%d") expected = "%s-%s" % (indexName, today) result = generateFullIndexName(indexName) self.assertEqual(result, expected)
def setUp(self): self.el = ElasticSearchDB(elHost, elPort) result = generateFullIndexName("integrationtest") self.assert_(len(result) > len("integrationtest")) self.index_name = result
def test_deleteIndex(self): result = generateFullIndexName("integrationtest") res = self.el.deleteIndex(result) self.assert_(res["OK"]) self.assertEqual(res["Value"], result)