diff options
author | Henrik <henrik.hoiness@online.no> | 2018-08-06 15:06:55 +0200 |
---|---|---|
committer | Henrik <henrik.hoiness@online.no> | 2018-08-06 15:06:55 +0200 |
commit | 0974a23733889a8396eb4d783bacc9a5c9663ad3 (patch) | |
tree | 107af5a2470775bd407a2c7e5561fc3b87355a18 /container-search | |
parent | f6cbbf8862da1ba9972cf6509c754afa4037c74d (diff) |
Changed queryFromRequest to requestMapFromRequest, and creating queryProfile and Query out of that map
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/Query.java | 3 | ||||
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java | 22 |
2 files changed, 8 insertions, 17 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/Query.java b/container-search/src/main/java/com/yahoo/search/Query.java index cf3e558878e..4c7005811ee 100644 --- a/container-search/src/main/java/com/yahoo/search/Query.java +++ b/container-search/src/main/java/com/yahoo/search/Query.java @@ -188,7 +188,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { public static final CompoundName GROUPING_SESSION_CACHE = new CompoundName("groupingSessionCache"); public static final CompoundName TIMEOUT = new CompoundName("timeout"); - private Map<String, String> requestMap; private static QueryProfileType argumentType; static { @@ -212,7 +211,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { } public static QueryProfileType getArgumentType() { return argumentType; } - public Map<String, String> getRequestMap() { return this.requestMap; } /** The aliases of query properties */ private static Map<String,CompoundName> propertyAliases; @@ -327,7 +325,6 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { private void init(Map<String, String> requestMap, CompiledQueryProfile queryProfile) { startTime = System.currentTimeMillis(); - this.requestMap = requestMap; if (queryProfile != null) { // Move all request parameters to the query profile just to validate that the parameter settings are legal Properties queryProfileProperties = new QueryProfileProperties(queryProfile); diff --git a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java index 1ca8feed451..9eaecea008e 100644 --- a/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java +++ b/container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java @@ -284,14 +284,15 @@ public class SearchHandler extends LoggingRequestHandler { private HttpSearchResponse handleBody(HttpRequest request){ - boolean benchmarkOutput = VespaHeaders.benchmarkOutput(request); - - Query query = queryFromRequest(request); + Map<String, String> requestMap = requestMapFromRequest(request); // Get query profile - String queryProfileName = query.getRequestMap().getOrDefault("queryProfile", null); + String queryProfileName = requestMap.getOrDefault("queryProfile", null); CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName); + Query query = new Query(request, requestMap, queryProfile); + + boolean benchmarkOutput = VespaHeaders.benchmarkOutput(request); boolean benchmarkCoverage = VespaHeaders.benchmarkCoverage(benchmarkOutput, request.getJDiscRequest().headers()); // Find and execute search chain if we have a valid query @@ -560,7 +561,7 @@ public class SearchHandler extends LoggingRequestHandler { return searchChainRegistry; } - private Query queryFromRequest(HttpRequest request){ + private Map<String, String> requestMapFromRequest(HttpRequest request) { if (request.getMethod() == com.yahoo.jdisc.http.HttpRequest.Method.POST && JSON_CONTENT_TYPE.equals(request.getHeader(com.yahoo.jdisc.http.HttpHeaders.Names.CONTENT_TYPE))) { @@ -579,18 +580,11 @@ public class SearchHandler extends LoggingRequestHandler { // Create request-mapping Map<String, String> requestMap = new HashMap<>(); createRequestMapping(inspector, requestMap, ""); - - String queryProfileName = requestMap.getOrDefault("queryProfile", null); - CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName); - - return new Query(request, requestMap, queryProfile); + return requestMap; } else { - String queryProfileName = request.getProperty("queryProfile"); - CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName); - - return new Query(request, queryProfile); + return request.propertyMap(); } } |