def search_results(request): lang = request.GET.get('lang', request.LANGUAGE_CODE) query = build_search_results_dsl(request) # logging.warning("\n\nQUERY: ----\n%s\n\n", query) search_related_resources = JSONDeserializer().deserialize(request.GET.get('searchRelatedResources')) if search_related_resources: results_from_prev_query = request.session['result-resource-ids'] related_resources_from_prev_query = list(get_related_resource_ids(results_from_prev_query, lang, start=0, limit=1000000)) ids_filter = Terms(field='entityid', terms=related_resources_from_prev_query) query.add_filter(ids_filter) results = query.search(index='entity', doc_type='') total = results['hits']['total'] page = 1 if request.GET.get('page') == '' else int(request.GET.get('page', 1)) all_entity_ids = ['_all'] if request.GET.get('include_ids', 'false') == 'false': all_entity_ids = ['_none'] elif request.GET.get('no_filters', '') == '': full_results = query.search(index='entity', doc_type='', start=0, limit=1000000, fields=[]) all_entity_ids = [hit['_id'] for hit in full_results['hits']['hits']] start = request.GET.get('start', 0) if not search_related_resources: # Store in session for next related resources search request.session['result-resource-ids'] = all_entity_ids return get_paginator(results, total, page, settings.SEARCH_ITEMS_PER_PAGE, all_entity_ids)
def search_results(request): query = build_search_results_dsl(request) #print query results = query.search(index='entity', doc_type='') total = results['hits']['total'] page = 1 if request.GET.get('page') == '' else int(request.GET.get('page', 1)) all_entity_ids = ['_all'] if request.GET.get('include_ids', 'false') == 'false': all_entity_ids = ['_none'] elif request.GET.get('no_filters', '') == '': full_results = query.search(index='entity', doc_type='', start=0, limit=1000000, fields=[]) all_entity_ids = [hit['_id'] for hit in full_results['hits']['hits']] return get_paginator(results, total, page, settings.SEARCH_ITEMS_PER_PAGE, all_entity_ids)
def search_results(request): query = build_search_results_dsl(request) results = query.search(index="entity", doc_type="") total = results["hits"]["total"] page = 1 if request.GET.get("page") == "" else int(request.GET.get("page", 1)) all_entity_ids = ["_all"] if request.GET.get("include_ids", "false") == "false": all_entity_ids = ["_none"] elif request.GET.get("no_filters", "") == "": full_results = query.search(index="entity", doc_type="", start=0, limit=1000000, fields=[]) all_entity_ids = [hit["_id"] for hit in full_results["hits"]["hits"]] return get_paginator(results, total, page, settings.SEARCH_ITEMS_PER_PAGE, all_entity_ids)
def search_results(request): lang = request.GET.get('lang', request.LANGUAGE_CODE) query = build_search_results_dsl(request) # logging.warning("\n\nQUERY: ----\n%s\n\n", query) search_related_resources = JSONDeserializer().deserialize( request.GET.get('searchRelatedResources')) if search_related_resources: results_from_prev_query = request.session['result-resource-ids'] related_resources_from_prev_query = list( get_related_resource_ids(results_from_prev_query, lang, start=0, limit=1000000)) ids_filter = Terms(field='entityid', terms=related_resources_from_prev_query) query.add_filter(ids_filter) results = query.search(index='entity', doc_type='') total = results['hits']['total'] page = 1 if request.GET.get('page') == '' else int( request.GET.get('page', 1)) all_entity_ids = ['_all'] if request.GET.get('include_ids', 'false') == 'false': all_entity_ids = ['_none'] elif request.GET.get('no_filters', '') == '': full_results = query.search(index='entity', doc_type='', start=0, limit=1000000, fields=[]) all_entity_ids = [hit['_id'] for hit in full_results['hits']['hits']] start = request.GET.get('start', 0) if not search_related_resources: # Store in session for next related resources search request.session['result-resource-ids'] = all_entity_ids return get_paginator(results, total, page, settings.SEARCH_ITEMS_PER_PAGE, all_entity_ids)
def search_results(request): allowed_types = get_allowed_types(request) query = build_search_results_dsl(request) # filter protected resources for any non-logged in users if request.user.username == "anonymous": query = add_neg_filter(query) results = query.search(index="entity", doc_type=allowed_types) total = results["hits"]["total"] page = 1 if request.GET.get("page") == "" else int(request.GET.get("page", 1)) all_entity_ids = ["_all"] if request.GET.get("include_ids", "false") == "false": all_entity_ids = ["_none"] elif request.GET.get("no_filters", "") == "": full_results = query.search(index="entity", doc_type="", start=0, limit=1000000, fields=[]) all_entity_ids = [hit["_id"] for hit in full_results["hits"]["hits"]] return get_paginator(results, total, page, settings.SEARCH_ITEMS_PER_PAGE, all_entity_ids)