summaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorHenrik <henrik.hoiness@online.no>2018-07-30 14:08:13 +0200
committerHenrik <henrik.hoiness@online.no>2018-07-30 14:08:13 +0200
commitf6cbbf8862da1ba9972cf6509c754afa4037c74d (patch)
treec2a774c28043f3a2b8a57871b5d6edb1bf0a0eac /container-search
parent0a5e370b59373d8147e2a8e682bc3296eec0d639 (diff)
Solved queryProfile always being null when using JSON-query. QueryProfile was set before getting the JSON-payload with queryProfileName
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/main/java/com/yahoo/search/Query.java5
-rw-r--r--container-search/src/main/java/com/yahoo/search/handler/SearchHandler.java20
2 files changed, 20 insertions, 5 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 cbc8b15eff9..cf3e558878e 100644
--- a/container-search/src/main/java/com/yahoo/search/Query.java
+++ b/container-search/src/main/java/com/yahoo/search/Query.java
@@ -188,6 +188,8 @@ 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 {
argumentType = new QueryProfileType("native");
@@ -210,6 +212,8 @@ 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;
static {
@@ -323,6 +327,7 @@ 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 3bfaee658f9..1ca8feed451 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
@@ -283,12 +283,14 @@ public class SearchHandler extends LoggingRequestHandler {
private HttpSearchResponse handleBody(HttpRequest request){
- // Find query profile
- String queryProfileName = request.getProperty("queryProfile");
- CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName);
+
boolean benchmarkOutput = VespaHeaders.benchmarkOutput(request);
- Query query = queryFromRequest(request, queryProfile);
+ Query query = queryFromRequest(request);
+
+ // Get query profile
+ String queryProfileName = query.getRequestMap().getOrDefault("queryProfile", null);
+ CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName);
boolean benchmarkCoverage = VespaHeaders.benchmarkCoverage(benchmarkOutput, request.getJDiscRequest().headers());
@@ -558,7 +560,8 @@ public class SearchHandler extends LoggingRequestHandler {
return searchChainRegistry;
}
- private Query queryFromRequest(HttpRequest request, CompiledQueryProfile queryProfile){
+ private Query queryFromRequest(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))) {
Inspector inspector;
@@ -576,10 +579,17 @@ 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);
} else {
+ String queryProfileName = request.getProperty("queryProfile");
+ CompiledQueryProfile queryProfile = queryProfileRegistry.findQueryProfile(queryProfileName);
+
return new Query(request, queryProfile);
}