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();
JSONArray ja = new JSONArray();
for(SearchResult result: results.getResults()) {
addResult(ja, result);
}
JSONObject jo = createResponse(q, searchTime, ja, matches, facets, didYouMean);