Exemple #1
0
def query_update(index, body):
    """Update all documents matching the given query."""
    for attempt in count():
        try:
            es.update_by_query(index=index,
                               body=body,
                               conflicts='proceed',
                               timeout=TIMEOUT,
                               request_timeout=REQUEST_TIMEOUT)
            return
        except Exception as exc:
            log.warning("Query update failed: %s", exc)
        backoff_cluster(failures=attempt)
Exemple #2
0
def update_roles(collection):
    """Update the role visibility of objects which are part of collections."""
    roles = ', '.join([str(r) for r in collection.roles])
    body = {
        'query': {
            'term': {
                'collection_id': collection.id
            }
        },
        'script': {
            'inline': 'ctx._source.roles = [%s]' % roles
        }
    }
    es.update_by_query(index=entity_index(),
                       body=body,
                       wait_for_completion=False)