def delete_snapshot_nodes_by_id(id_list): if not isinstance(id_list, list): id_list = [id_list] es = Common.get_elasticsearch().get_connection() for i in id_list: try: es.delete(index=SNAPSHOT_INDEX, doc_type=SNAPSHOT_DOC_TYPE, id=i) except ElasticsearchException, e: Common.get_logger().error('Error deleting node<%s>\n%s' % (i, e))
def execute_query(query, **kwargs): es = Common.get_elasticsearch().get_connection() try: response = es.search(index=SNAPSHOT_INDEX, doc_type=SNAPSHOT_DOC_TYPE, body=query, **kwargs) return response except ElasticsearchException, e: Common.get_logger().error('Error ES query execution\n%s' % e)
def insert_into_snapshot(inputs): data = [] for item in inputs: data.append(inputs[item]) Common.get_elasticsearch().put_bulk_data(SNAPSHOT_INDEX, SNAPSHOT_DOC_TYPE, data)