Example #1
0
def delete_entity(entity_id, exclude=None, sync=False):
    """Delete an entity from the index."""
    query = {'query': {'ids': {'values': str(entity_id)}}}
    es.delete_by_query(index=entities_read_index(exclude=exclude),
                       body=query,
                       wait_for_completion=sync,
                       refresh=refresh_sync(sync))
Example #2
0
File: admin.py Project: pudo/aleph
def clear_index():
    es.delete_by_query(index=all_indexes(),
                       body={'query': {'match_all': {}}},
                       refresh=True,
                       wait_for_completion=True,
                       conflicts='proceed',
                       ignore=[404])
Example #3
0
def query_delete(query, doc_type=None, wait=True):
    "Delete all documents matching the given query inside the doc_type(s)."
    es.delete_by_query(index=six.text_type(es_index),
                       body={'query': query},
                       doc_type=doc_type,
                       refresh=True,
                       conflicts='proceed',
                       wait_for_completion=wait)
Example #4
0
def clear_index():
    q = {'query': {'match_all': {}}}
    refresh_index()
    es.delete_by_query(index=all_indexes(),
                       body=q,
                       refresh=True,
                       wait_for_completion=True,
                       conflicts='proceed')
Example #5
0
def query_delete(index, query):
    "Delete all documents matching the given query inside the index."
    try:
        es.delete_by_query(index=index,
                           body={'query': query},
                           conflicts='proceed',
                           timeout=TIMEOUT,
                           request_timeout=REQUEST_TIMEOUT)
    except TransportError as terr:
        log.warning("Query delete failed: %s", terr)
Example #6
0
def query_delete(index, query):
    "Delete all documents matching the given query inside the index."
    for attempt in count():
        try:
            es.delete_by_query(index=index,
                               body={'query': query},
                               conflicts='proceed',
                               timeout=TIMEOUT,
                               request_timeout=REQUEST_TIMEOUT)
            return
        except Exception as exc:
            log.warning("Query delete failed: %s", exc)
        backoff_cluster(failures=attempt)
Example #7
0
File: util.py Project: pudo/aleph
def query_delete(index, query, sync=False, **kwargs):
    "Delete all documents matching the given query inside the index."
    for attempt in service_retries():
        try:
            es.delete_by_query(index=index,
                               body={'query': query},
                               conflicts='proceed',
                               wait_for_completion=sync,
                               refresh=refresh_sync(sync),
                               **kwargs)
            return
        except TransportError as exc:
            log.warning("Query delete failed: %s", exc)
            backoff(failures=attempt)
Example #8
0
    def setUp(self):
        self.flush_index()
        if not hasattr(TestCase, '_global_test_state'):
            TestCase._global_test_state = True
            delete_index()
            upgrade_search()
        else:
            es.delete_by_query(index=all_indexes(),
                               body={'query': {'match_all': {}}},
                               refresh=True,
                               conflicts='proceed')

        destroy_db()
        db.create_all()
        create_system_roles()
Example #9
0
def query_delete(index, query, **kwargs):
    "Delete all documents matching the given query inside the index."
    for attempt in service_retries():
        try:
            es.delete_by_query(index=index,
                               body={'query': query},
                               conflicts='proceed',
                               timeout=TIMEOUT,
                               request_timeout=REQUEST_TIMEOUT,
                               **kwargs)
            return
        except RequestError:
            raise
        except Exception as exc:
            log.warning("Query delete failed: %s", exc)
        backoff(failures=attempt)
Example #10
0
def clear_index():
    indexes = [collection_index(), entity_index(), record_index()]
    q = {'query': {'match_all': {}}}
    es.delete_by_query(index=indexes, body=q, refresh=True)