示例#1
0
 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')
示例#2
0
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)})
示例#3
0
 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')
示例#4
0
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
示例#5
0
def es_delete(index, eid):
    es.delete(index=index, doc_type='digest', id=eid)
示例#6
0
def remove_from_index(model):
    es.delete(index='datasets', doc_type='_doc', id=model.id)
示例#7
0
def remove_from_index(index, model):
    if not es:
        return
    es.delete(index=index, id=model.id)
示例#8
0
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)
示例#9
0
def remove_from_index(index, model):
    if not elasticsearch:
        return
    elasticsearch.delete(index=index, doc_type=index, id=model.id)
示例#10
0
def delete(index, model):
    if es:
        es.delete(index=index, id=model.id)