diff options
Diffstat (limited to 'container-search')
8 files changed, 28 insertions, 15 deletions
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json index 8fbf12b16b4..afaf449a432 100644 --- a/container-search/abi-spec.json +++ b/container-search/abi-spec.json @@ -2119,6 +2119,7 @@ "public com.yahoo.search.Query clone()", "public com.yahoo.search.query.Presentation getPresentation()", "public com.yahoo.search.query.Select getSelect()", + "public void setSelect(java.lang.String)", "public com.yahoo.search.query.Ranking getRanking()", "public com.yahoo.search.query.Model getModel()", "public com.yahoo.search.query.Trace getTrace()", 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 e01d03e96a7..8e0897b866f 100644 --- a/container-search/src/main/java/com/yahoo/search/Query.java +++ b/container-search/src/main/java/com/yahoo/search/Query.java @@ -384,9 +384,11 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { // We need special handling for "select" because it can be both the prefix of the nested JSON select // parameters, and a plain select expression. The latter will be disallowed by query profile types // since they contain the former. - String select = requestMap.get(Select.SELECT); + Object select = requestMap.get(Select.SELECT); + if (select == null) + select = queryProfile.get(Select.SELECT, requestMap); if (select != null) - properties().set(Select.SELECT, select); + properties().set(Select.SELECT, select.toString()); } else { // bypass these complications if there is no query profile to get values from and validate against properties(). @@ -906,6 +908,9 @@ public class Query extends com.yahoo.processing.Request implements Cloneable { /** Returns the select to be used for this query, never null */ public Select getSelect() { return select; } + /** Sets the select (grouping) parameter from a string. */ + public void setSelect(String groupingString) { select.setGroupingExpressionString(groupingString); } + /** Returns the ranking to be used for this query, never null */ public Ranking getRanking() { return ranking; } diff --git a/container-search/src/main/java/com/yahoo/search/query/Select.java b/container-search/src/main/java/com/yahoo/search/query/Select.java index 6735a6bd050..38ef7b8f190 100644 --- a/container-search/src/main/java/com/yahoo/search/query/Select.java +++ b/container-search/src/main/java/com/yahoo/search/query/Select.java @@ -115,9 +115,7 @@ public class Select implements Cloneable { public String getGroupingExpressionString() { return groupingExpressionString; } /** Returns the grouping in the query */ - public String getGroupingString(){ - return grouping; - } + public String getGroupingString() { return grouping; } /** * Returns the query's {@link GroupingRequest} as a mutable list. Changing this directly changes the grouping diff --git a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java index cafb79d8542..ca7d5bf6999 100644 --- a/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/hitfield/test/JSONStringTestCase.java @@ -740,13 +740,6 @@ public class JSONStringTestCase { Inspector value5 = new JSONString("{\"foo\":1}").inspect(); Inspector value6 = new JSONString("[1,2,3]").inspect(); - System.out.println("1: " + value1); - System.out.println("2: " + value2); - System.out.println("3: " + value3); - System.out.println("4: " + value4); - System.out.println("5: " + value5); - System.out.println("6: " + value6); - assertEquals(Type.STRING, value1.type()); assertEquals("", value1.asString()); diff --git a/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java index 5b20eda4344..5e0da17c186 100644 --- a/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/query/ItemHelperTestCase.java @@ -34,7 +34,6 @@ public class ItemHelperTestCase { ItemHelper helper = new ItemHelper(); Query q = new Query("/?query=" + enc("a b c \"d e\" -f")); List<IndexedItem> l = new ArrayList<>(); - System.out.println(q.getModel()); helper.getPositiveTerms(q.getModel().getQueryTree().getRoot(), l); assertEquals(4, l.size()); boolean a = false; diff --git a/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java b/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java index 4cd453746bb..2f36d174ad4 100644 --- a/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java +++ b/container-search/src/test/java/com/yahoo/search/dispatch/TopKEstimatorTest.java @@ -88,7 +88,7 @@ public class TopKEstimatorTest { @Test void requireThatLargeKAreSane() { - System.out.println(dumpProbability(10, 0.05)); + // System.out.println(dumpProbability(10, 0.05)); TopKEstimator idealEstimator = new TopKEstimator(30, 0.9999); TopKEstimator skewedEstimator = new TopKEstimator(30, 0.9999, 0.05); int [] K = {10, 20, 40, 80, 100, 200, 400, 800, 1000, 2000, 4000, 8000, 10000, 20000, 40000, 80000, 100000}; diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java index 357bba0c7b1..7cbd5747d2d 100644 --- a/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java @@ -25,7 +25,6 @@ public class DumpToolTestCase { @Test void testNoDimensionValues() { - System.out.println(new DumpTool().resolveAndDump("multiprofile1", profileDir)); assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir).contains("a=general-a\n")); } diff --git a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java index 6a310180eab..259a79b095b 100644 --- a/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java @@ -306,6 +306,24 @@ public class QueryTestCase { assertEquals("Profile: myProfile", q.properties().get("myField")); } + /** Select is special handled due to the strange idea to also use it to contain subproperties with JSON. */ + @Test + void testQueryProfileWithSelect() { + String grouping = "all(group(customerid) each(output(count())))"; + + { // select in the request + QueryProfile profile = new QueryProfile("myProfile"); + Query q = new Query(QueryTestCase.httpEncode("/search?query=macbook&queryProfile=myProfile&select=" + grouping), profile.compile(null)); + assertEquals(grouping, q.getSelect().getGroupingExpressionString()); + } + { // select in the query profile + QueryProfile profile = new QueryProfile("myProfile"); + profile.set("select", grouping, null); + Query q = new Query(QueryTestCase.httpEncode("/search?query=macbook&queryProfile=myProfile"), profile.compile(null)); + assertEquals(grouping, q.getSelect().getGroupingExpressionString()); + } + } + @Test void testQueryProfileSourceAccess() { QueryProfile profile = new QueryProfile("myProfile"); |