/**
* @see java.lang.Runnable#run()
*/
public void run() {
IndexEngineApi api = (IndexEngineApi) ctx().getAttribute("api");
HttpServletResponse res = res();
String characterEncoding = api.getCharacterEncoding();
try {
req().setCharacterEncoding(characterEncoding);
res.setCharacterEncoding(characterEncoding);
res.setContentType("application/json");
} catch (UnsupportedEncodingException ignored) {
}
String q = params("q");
String fetchVariables = params("fetch_variables");
String fetchCategories = params("fetch_categories");
String fetch = params("fetch");
String snippet = params("snippet");
int start = QueryHelper.parseIntParam(params("start"), 0);
int len = QueryHelper.parseIntParam(params("len"), 10);
int function = QueryHelper.parseIntParam(params("function"), 0);
Map<Integer, Double> vars = Maps.newHashMap();
List<CategoryFilter> facetFilters = Lists.newArrayList();
List<RangeFilter> variableRangeFilters = Lists.newArrayList();
List<RangeFilter> functionRangeFilters = Lists.newArrayList();
Map<String, String> extras = createExtraParameters(fetch, snippet,
fetchVariables, fetchCategories);
try {
long t0 = System.currentTimeMillis();
SearchResults results = api.search(q, start, len, function, vars, facetFilters, variableRangeFilters, functionRangeFilters, extras);
long t1 = System.currentTimeMillis();
double searchTime = (t1 - t0) / 1000;
int matches = results.getMatches();
Map<String, Map<String, Integer>> facets = toFacets(results.getFacets());
String didYouMean = results.getDidYouMean();