Beispiel #1
0
def statistics():
    collections = authz.collections(authz.READ)
    enable_cache(vary=collections)
    query = documents_query(MultiDict())
    query["size"] = 0
    result = execute_documents_query(MultiDict(), query)
    # collections = Collection.category_statistics(collections)
    return jsonify({"document_count": result["total"], "collection_count": len(collections)})
Beispiel #2
0
def query():
    enable_cache(vary_user=True, vary=authz.collections(authz.READ))
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Beispiel #3
0
def statistics():
    collections = authz.collections(authz.READ)
    enable_cache(vary=collections)
    query = documents_query(MultiDict())
    query['size'] = 0
    result = execute_documents_query(MultiDict(), query)
    # collections = Collection.category_statistics(collections)
    return jsonify({
        'document_count': result['total'],
        'collection_count': len(collections)
    })
Beispiel #4
0
def query():
    enable_cache(vary_user=True,
                 vary=authz.collections(authz.READ))
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Beispiel #5
0
def query():
    enable_cache(vary_user=True, vary=authz.collections(authz.READ))
    query = documents_query(request.args)
    query["size"] = get_limit(default=100)
    query["from"] = get_offset()
    # import json
    # print json.dumps(query, indent=2)
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    log_event(request)
    if params is not None:
        result["next"] = url_for("search_api.query", **params)
    return jsonify(result)
Beispiel #6
0
def query():
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    result['alert'] = None
    if authz.logged_in():
        result['alert'] = Alert.exists(request.args, request.auth_role)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Beispiel #7
0
def query():
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    result['alert'] = None
    if authz.logged_in():
        result['alert'] = Alert.exists(request.args, request.auth_role)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return jsonify(result)
Beispiel #8
0
def _query(escape=False):
    '''
    everything here should be applicable both to the internal and to the
    public api
    '''
    creds = authz.collections(authz.READ), authz.sources(authz.READ)
    enable_cache(vary_user=True, vary=creds)
    query = documents_query(request.args, escape=escape)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    result = execute_documents_query(request.args, query)
    params = next_params(request.args, result)
    if params is not None:
        result['next'] = url_for('search_api.query', **params)
    return result
Beispiel #9
0
def query():
    etag_cache_keygen()
    query = documents_query(request.args)
    query['size'] = get_limit(default=100)
    query['from'] = get_offset()
    return jsonify(execute_documents_query(request.args, query))