def _get_child_concepts(conceptid): se = SearchEngineFactory().create() ret = se.search(conceptid, index='concept', type='all', search_field='conceptid', use_phrase=True) left = ret['hits']['hits'][0]['_source']['left'] right = ret['hits']['hits'][0]['_source']['right'] concepts = se.search({ 'from': left, 'to': right }, index='concept', type='all', search_field='left', use_range=True) ret = [] for concept in concepts['hits']['hits']: for label in concept['_source']['labels']: ret.append(label['labelid']) return ret
def search_terms(request): se = SearchEngineFactory().create() searchString = request.GET['q'] return HttpResponse(JSONSerializer().serialize(se.search( searchString.lower(), index='term', type='value', search_field='term', use_fuzzy=True), ensure_ascii=False))
def Search(request): se = SearchEngineFactory().create() searchString = request.GET['q'] search_results = _normalize_spatial_results_to_wkt( se.search(searchString.lower(), index='entity', type='', search_field='strings', use_phrase=True)) return HttpResponse(JSONSerializer().serialize(search_results, ensure_ascii=False))
def MapLayers(request, entitytypeid): data = [] bbox = request.GET['bbox'] limit = request.GET.get('limit', 10000) try: se = SearchEngineFactory().create() data = se.search('', index="maplayers", type=entitytypeid, end_offset=limit) except: pass return HttpResponse(JSONSerializer().serialize(data, ensure_ascii=True, indent=4))
def Concept(request, ids): full_graph = request.GET.get('full_graph', 'true') == 'true' exclude_subconcepts = request.GET.get('exclude_subconcepts', 'false') == 'true' exclude_parentconcepts = request.GET.get('exclude_parentconcepts', 'false') == 'true' exclude_notes = request.GET.get('exclude_notes', 'false') == 'true' exclude_labels = request.GET.get('exclude_labels', 'false') == 'true' exclude_metadata = request.GET.get('exclude_metadata', 'false') == 'true' emulate_elastic_search = request.GET.get('emulate_elastic_search', 'true') == 'true' fromdb = request.GET.get('fromdb', 'false') == 'true' ret = [] if request.method == 'GET': if fromdb: for id in ids.split(','): if ".E" in id: entitytype = archesmodels.EntityTypes.objects.get(pk=id) concept = entitytype.conceptid else: concept = archesmodels.Concepts.objects.get(conceptid=id) concept_graph = concept.toObject( full_graph=full_graph, exclude_subconcepts=exclude_subconcepts, exclude_parentconcepts=exclude_parentconcepts, exclude_notes=exclude_notes, exclude_labels=exclude_labels, exclude_metadata=exclude_metadata) if emulate_elastic_search: ret.append({'_type': id, '_source': concept_graph}) else: ret.append(concept_graph) if emulate_elastic_search: ret = {'hits': {'hits': ret}} else: se = SearchEngineFactory().create() ret = se.search('', index='concept', type=ids, search_field='value', use_wildcard=True) return HttpResponse(JSONSerializer().serialize(ret, ensure_ascii=True, indent=4))
def Concept(request, ids): full_graph = request.GET.get('full_graph', 'true') == 'true' exclude_subconcepts = request.GET.get('exclude_subconcepts', 'false') == 'true' exclude_parentconcepts = request.GET.get('exclude_parentconcepts', 'false') == 'true' exclude_notes = request.GET.get('exclude_notes', 'false') == 'true' exclude_labels = request.GET.get('exclude_labels', 'false') == 'true' exclude_metadata = request.GET.get('exclude_metadata', 'false') == 'true' emulate_elastic_search = request.GET.get('emulate_elastic_search', 'true') == 'true' fromdb = request.GET.get('fromdb', 'false') == 'true' ret = [] if request.method == 'GET': if fromdb: for id in ids.split(','): if ".E" in id: entitytype = archesmodels.EntityTypes.objects.get(pk = id) concept = entitytype.conceptid else: concept = archesmodels.Concepts.objects.get(conceptid = id) concept_graph = concept.toObject(full_graph=full_graph, exclude_subconcepts=exclude_subconcepts, exclude_parentconcepts=exclude_parentconcepts, exclude_notes=exclude_notes, exclude_labels=exclude_labels, exclude_metadata=exclude_metadata) if emulate_elastic_search: ret.append({'_type': id, '_source': concept_graph}) else: ret.append(concept_graph) if emulate_elastic_search: ret = {'hits':{'hits':ret}} else: se = SearchEngineFactory().create() ret = se.search('', index='concept', type=ids, search_field='value', use_wildcard=True) return HttpResponse(JSONSerializer().serialize(ret, ensure_ascii=True, indent=4))