예제 #1
0
def docs_this_week():
    '''
    Return how many documents have been added
    to the index this week
    '''
    query = {'query': {'range': {'created_at': {'gte': 'now-7d/d'}}}}
    res = search_documents(query)
    return res.result['hits']['total']
예제 #2
0
파일: search_api.py 프로젝트: nightsh/aleph
def query():
    etag_cache_keygen()
    query = document_query(request.args, lists=authz.authz_lists('read'),
                           sources=authz.authz_sources('read'))
    results = search_documents(query)
    pager = Pager(results,
                  results_converter=lambda ds: [add_urls(d) for d in ds])
    data = pager.to_dict()
    data['facets'] = transform_facets(results.result.get('aggregations', {}))
    return jsonify(data)
예제 #3
0
def _query():
    '''
    everything here should be applicable both to the internal and to the
    public api
    '''
    etag_cache_keygen()
    query = document_query(request.args, lists=authz.authz_lists('read'),
                           sources=authz.authz_sources('read'),
                           highlights=True)
    results = search_documents(query)
    pager = Pager(results,
                  results_converter=lambda ds: [add_urls(d) for d in ds])
    data = pager.to_dict()
    #import ipdb; ipdb.set_trace()
    data['facets'] = transform_facets(results.result.get('aggregations', {}))
    return data
예제 #4
0
파일: search_api.py 프로젝트: vied12/aleph
def _query():
    '''
    everything here should be applicable both to the internal and to the
    public api
    '''
    etag_cache_keygen()
    query = document_query(request.args,
                           lists=authz.authz_lists('read'),
                           sources=authz.authz_sources('read'),
                           highlights=True)
    results = search_documents(query)
    pager = Pager(results,
                  results_converter=lambda ds: [add_urls(d) for d in ds])
    data = pager.to_dict()
    #import ipdb; ipdb.set_trace()
    data['facets'] = transform_facets(results.result.get('aggregations', {}))
    return data
예제 #5
0
def run_alert(al):
    query = build_query(al)
    results = search_documents(query)
    if should_mail_results(al, results):
        mail_results(al, results)
예제 #6
0
파일: alerts.py 프로젝트: OpenOil-UG/aleph
def run_alert(al):
    query = build_query(al)
    results = search_documents(query)
    if should_mail_results(al, results):
        mail_results(al, results)