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']
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)
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
def run_alert(al): query = build_query(al) results = search_documents(query) if should_mail_results(al, results): mail_results(al, results)