def test_write_es(self): es.indices.create(index='test-index', ignore=[400]) es_json = [{"test": "hello world"}] write_es(es_json, '123') twrite = es.get(id='123', index='test-index') source = twrite['_source'] self.assertEqual(source, {"test": "hello world"}) es.delete(id='123', index='test-index', doc_type='document')
def delete_word(): idn = request.args['id'] #in case of get(args[]) try: es.delete("dict_word", doc_type="word", id=idn) return jsonify({"response": "success"}) except Exception as e: print str(e) return jsonify({"response": "failure", "error": str(e)})
def test_write_index(self): write_index(bundle_uuid) file_ids = [ 'b1db2bf9-855a-4961-ae39-be2a8d6aa864:52d4f049-2c9a-4a75-8dd4-' '9559902e67bd:2017-09-22T001551.542119Z', 'b1db2bf9-855a-4961-ae39-be2a8d6aa864:cd6c128b-cf1f-49dc-b3d8-' '1eb39115f90e:2017-09-22T001552.608139Z' ] for i in range(1, len(file_ids)): twrite = es.get(id=file_ids[i], index='test-index') source = twrite['_source'] self.assertEqual(source, expected_index[i]) es.delete(id=file_ids[i], index='test-index', doc_type='document')
def delete_from_es(model_instance): """ Deletes an item/s from the elastic search index (note will get copies) :param model_instance: The model object to be deleted. :return: Bool """ json = model_instance.jsonify() model_name = model_instance.__class__.__name__.lower() s = Search(using=es, index=model_name, doc_type=model_name).query('match', url=model_instance.url) s.execute() for item in s: result = es.delete(index=model_name, doc_type=model_name, id=item.meta.id) logger.info('Deleted from elasticsearch: %s', result) break return True
def es_delete(index, eid): es.delete(index=index, doc_type='digest', id=eid)
def remove_from_index(model): es.delete(index='datasets', doc_type='_doc', id=model.id)
def remove_from_index(index, model): if not es: return es.delete(index=index, id=model.id)
def delete_doc(suborder_id): """Delete a specific doc in the index""" es.delete(index=current_app.config['ELASTICSEARCH_INDEX'], doc_type=current_app.config["ELASTICSEARCH_INDEX"], id=suborder_id)
def remove_from_index(index, model): if not elasticsearch: return elasticsearch.delete(index=index, doc_type=index, id=model.id)
def delete(index, model): if es: es.delete(index=index, id=model.id)