Exemplo n.º 1
0
def delete_collection(collection_id, wait=True):
    """Delete all documents from a particular collection."""
    query_delete({'term': {'collection_id': collection_id}}, wait=wait)
    es.delete(index=es_index,
              doc_type=TYPE_COLLECTION,
              id=collection_id,
              ignore=[404])
Exemplo n.º 2
0
def delete_collection(collection_id):
    """Delete all documents from a particular collection."""
    es.delete(index=collections_index(),
              doc_type='doc',
              refresh=True,
              id=collection_id,
              ignore=[404])
Exemplo n.º 3
0
def delete_collection(collection_id, sync=False):
    """Delete all documents from a particular collection."""
    es.delete(collections_index(),
              doc_type='doc',
              id=str(collection_id),
              refresh=sync,
              ignore=[404])
Exemplo n.º 4
0
def delete_collection(collection_id, sync=False):
    """Delete all documents from a particular collection."""
    es.delete(
        collections_index(),
        id=str(collection_id),
        refresh=refresh_sync(sync),
        ignore=[404],
    )
Exemplo n.º 5
0
def delete_collection(collection_id, wait=True):
    """Delete all documents from a particular collection."""
    delete_entities(collection_id, wait=wait)
    delete_documents(collection_id, wait=wait)
    es.delete(index=collections_index(),
              doc_type='doc',
              id=collection_id,
              ignore=[404])
Exemplo n.º 6
0
def delete_collection(collection_id, wait=True):
    """Delete all documents from a particular collection."""
    query = {'term': {'collection_id': collection_id}}
    query_delete(records_index(), query, wait=wait)
    query_delete(entities_index(), query, wait=wait)
    es.delete(index=collections_index(),
              doc_type=collection_type(),
              id=collection_id,
              ignore=[404])
Exemplo n.º 7
0
def delete_entity(entity_id, exclude=None, sync=False):
    """Delete an entity from the index."""
    if exclude is not None:
        exclude = entities_write_index(exclude)
    for entity in entities_by_ids(entity_id, excludes='*'):
        index = entity.get('_index')
        if index == exclude:
            continue
        es.delete(index=index, id=entity_id, refresh=refresh_sync(sync))
Exemplo n.º 8
0
def delete_entity(entity_id, exclude=None, sync=False):
    """Delete an entity from the index."""
    if exclude is not None:
        exclude = entities_write_index(exclude)
    for entity in entities_by_ids(entity_id, excludes='*'):
        index = entity.get('_index')
        if index == exclude:
            continue
        es.delete(index=index, id=entity_id,
                  refresh=refresh_sync(sync))
Exemplo n.º 9
0
def delete_entity(entity_id, exclude=None, sync=False):
    """Delete an entity from the index."""
    if exclude is not None:
        exclude = entities_write_index(exclude)
    for entity in entities_by_ids(entity_id, excludes='*'):
        index = entity.get('_index')
        if index == exclude:
            continue
        try:
            es.delete(index=index, id=entity_id, refresh=refresh_sync(sync))
            q = {'term': {'entities': entity_id}}
            query_delete(entities_read_index(), q, sync=sync)
        except NotFoundError:
            # This is expected in some cases. For example, when 2 Things are
            # connected by an Interval and all the 3 entities get deleted
            # simultaneously, Aleph tries to delete the Interval thrice due to
            # recursive deletion of adjacent entities. ElasticSearch throws a
            # 404 in that case.
            # In those cases, we want to skip both the `es.delete` step and
            # the `query_delete` step.
            log.warning("Delete failed for entity %s - not found", entity_id)
            continue
Exemplo n.º 10
0
def delete_document(document_id):
    clear_records(document_id)
    try:
        es.delete(index=es_index, doc_type=TYPE_DOCUMENT, id=document_id)
    except NotFoundError:
        pass
Exemplo n.º 11
0
def delete_collection(collection_id, sync=False):
    """Delete all documents from a particular collection."""
    es.delete(collections_index(),
              id=str(collection_id),
              refresh=refresh_sync(sync),
              ignore=[404])
Exemplo n.º 12
0
def delete_collection_entities():
    q = {'query': {'exists': {'field': 'collection_id'}}}
    for ent in scan(es, query=q, index=es_index, doc_type=[TYPE_ENTITY]):
        es.delete(index=es_index, doc_type=TYPE_ENTITY, id=ent.get('_id'))
Exemplo n.º 13
0
def delete_entity(entity_id):
    """Delete an entity from the index."""
    es.delete(index=es_index, doc_type=TYPE_ENTITY, id=entity_id, ignore=[404])
Exemplo n.º 14
0
def delete_document(document_id):
    clear_records(document_id)
    es.delete(index=es_index,
              doc_type=TYPE_DOCUMENT,
              id=document_id,
              ignore=[404])
Exemplo n.º 15
0
def delete_document(document_id):
    clear_records(document_id)
    try:
        es.delete(index=es_index, doc_type=TYPE_DOCUMENT, id=document_id)
    except NotFoundError:
        log.info("Delete non-existent document from index: %s", document_id)
Exemplo n.º 16
0
def delete_safe(index, id, sync=False):
    es.delete(index=index,
              id=str(id),
              ignore=[404],
              refresh=refresh_sync(sync))
Exemplo n.º 17
0
def delete_entity(entity_id, sync=False):
    """Delete an entity from the index."""
    refresh = 'wait_for' if sync else False
    for index in entities_index_list():
        es.delete(index=index, doc_type='doc', id=str(entity_id),
                  refresh=refresh, ignore=[404])
Exemplo n.º 18
0
def delete_entity(entity_id):
    """Delete an entity from the index."""
    es.delete(index=entities_index(),
              doc_type=entity_type(),
              id=entity_id,
              ignore=[404])
Exemplo n.º 19
0
def delete_document(document_id):
    clear_records(document_id)
    es.delete(index=entities_index(),
              doc_type=entity_type(),
              id=document_id,
              ignore=[404])
Exemplo n.º 20
0
def delete_entity(entity_id):
    """Delete an entity from the index."""
    for index in entities_index_list():
        es.delete(index=index, doc_type='doc', id=entity_id, ignore=[404])