Exemple #1
0
def return_points_khooshe(request, indexed_path, domain_name):
    '''
        Returns geo point for give file using khooshe
    '''
    core_name,_,_ = get_index_core(domain_name, indexed_path)

    total_docs, points_count = get_idx_details(domain_name, indexed_path)

    file_name = ''.join(ch for ch in core_name if ch not in exclude)

    results  = create_khooshe_result(GetIndexSize(core_name), total_docs, points_count, 
                                     get_idx_field_csv(domain_name, indexed_path),"static/tiles/{0}".format(file_name) )
    
    if results["rows_processed"]:
        return HttpResponse(status=200, content="[{0}]".format(results))
    else:
        return HttpResponse(status=400, content="Cannot find latitude and longitude(return_points_khooshe).")
Exemple #2
0
def search_crawled_index(request, indexed_path, domain_name, keyword):
    '''
    Searches a 'keyword' in 'indexed_path', using 'username', 'passwd'
    '''
    print "Searching for {0} in {1}".format(keyword, indexed_path)

    #Fetching stored data for domain name and index path from admin
    core_name, username, passwd = get_index_core(domain_name, indexed_path)
    
    keyword = urllib.quote_plus(keyword)

    url = "{0}/select?q=*{1}*&wt=json&rows=1".format(indexed_path, keyword)
    r = requests.get(url, headers=headers, auth=HTTPBasicAuth(username, passwd))

    if r.status_code != 200:
        return HttpResponse(status=r.status_code, content=r.reason)

    response = r.json()
    numFound = response['response']['numFound']
    list_id = []
    print "Total number of records found {0}".format(numFound)

    # limiting search count to MAX_SEARCH_RESULT 
    if numFound > MAX_SEARCH_RESULT:
        numFound = MAX_SEARCH_RESULT
        print "Processing only {0} records".format(numFound)

    for row in range(0, int(numFound), QUERY_RANGE):  # loop solr query
        docs = {}
        url = "{0}/select?q=*{1}*&start={2}&rows={3}&wt=json&fl=id".format(indexed_path, keyword, row, QUERY_RANGE)
        print "solr query - {0}".format(url)
        r = requests.get(url, headers=headers, auth=HTTPBasicAuth(username, passwd))
        response = r.json()
        docs = response['response']['docs']
        list_id += [doc["id"] for doc in docs]
    
    khooshe_tile_folder_name,points_count = SearchLocalSolrIndex(core_name, list_id, keyword)
    
    result = create_khooshe_result(len(list_id), GetIndexSize(core_name), points_count,
                                    get_idx_field_csv(domain_name, indexed_path), khooshe_tile_folder_name)

    if khooshe_tile_folder_name:
        return HttpResponse(status=200, content="[{0}]".format(str(result)))
    else:
        return HttpResponse(status=404, content="No points found for given search")
Exemple #3
0
def get_idx_fields_for_popup(request, domain_name, indexed_path):
    print "get popup fields"
    return HttpResponse(status=200, content=get_idx_field_csv(domain_name, indexed_path))