Esempio n. 1
0
def search_view(request):
  query = str(request.REQUEST['query'].strip())
  search_request = {
    'query' : query,
    'max_results' : int( request.REQUEST.get('max_results', 25) ),
    'keep_query_pattern' : int(request.REQUEST.get('keep_query_pattern', 0)),
  }
  #if not search_request['query'].endswith('*'):
  #  search_request['query'] += '*'

  results = sorted(searcher.search(**search_request))
  result_data = json.dumps( dict(metrics=results) )
  return HttpResponse(result_data, mimetype='text/json')
Esempio n. 2
0
def search_view(request):
  query = str(request.REQUEST['query'].strip())
  search_request = {
    'query' : query,
    'max_results' : int( request.REQUEST.get('max_results', 25) ),
    'keep_query_pattern' : int(request.REQUEST.get('keep_query_pattern', 0)),
  }
  #if not search_request['query'].endswith('*'):
  #  search_request['query'] += '*'

  results = sorted(searcher.search(**search_request))
  result_data = json.dumps( dict(metrics=results) )
  return HttpResponse(result_data, mimetype='application/json')
Esempio n. 3
0
def search_view(request):
  try:
    query = str( request.REQUEST['query'] )
  except:
    return HttpResponseBadRequest(content="Missing required parameter 'query'", mimetype="text/plain")
  search_request = {
    'query' : query,
    'max_results' : int( request.REQUEST.get('max_results', 25) ),
    'keep_query_pattern' : int(request.REQUEST.get('keep_query_pattern', 0)),
  }
  #if not search_request['query'].endswith('*'):
  #  search_request['query'] += '*'

  results = sorted(searcher.search(**search_request))
  return json_response_for(request, dict(metrics=results))
Esempio n. 4
0
def search_view(request):
  try:
    query = str( request.REQUEST['query'] )
  except:
    return HttpResponseBadRequest(content="Missing required parameter 'query'", content_type="text/plain")
  search_request = {
    'query' : query,
    'max_results' : int( request.REQUEST.get('max_results', 25) ),
    'keep_query_pattern' : int(request.REQUEST.get('keep_query_pattern', 0)),
  }
  #if not search_request['query'].endswith('*'):
  #  search_request['query'] += '*'

  results = sorted(searcher.search(**search_request))
  return json_response_for(request, dict(metrics=results))
Esempio n. 5
0
def search_view(request):
    try:
        query = str(request.REQUEST["query"])
    except:
        return HttpResponseBadRequest(content="Missing required parameter 'query'", mimetype="text/plain")
    search_request = {
        "query": query,
        "max_results": int(request.REQUEST.get("max_results", 25)),
        "keep_query_pattern": int(request.REQUEST.get("keep_query_pattern", 0)),
    }
    # if not search_request['query'].endswith('*'):
    #  search_request['query'] += '*'

    results = sorted(searcher.search(**search_request))
    result_data = json.dumps(dict(metrics=results))
    return HttpResponse(result_data, mimetype="application/json")