aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2022-02-07 23:21:36 +0100
committerGitHub <noreply@github.com>2022-02-07 23:21:36 +0100
commit154c8837f1ca166816d289db82fed90baca72e54 (patch)
treeb529a22e0b28e4f95e5398d1246deeb53798ee69 /container-search
parenta2b99d544beca9fdb8ae6a2d3b180536e07a7c61 (diff)
Revert "Bratseth/presentation format tensors"
Diffstat (limited to 'container-search')
-rw-r--r--container-search/abi-spec.json10
-rw-r--r--container-search/src/main/java/com/yahoo/search/Query.java16
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/Presentation.java99
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java4
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/PropertyAliases.java1
-rw-r--r--container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java48
-rw-r--r--container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java10
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/test/DumpToolTestCase.java7
-rw-r--r--container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java1
-rw-r--r--container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java27
-rw-r--r--container-search/src/test/java/com/yahoo/search/test/QueryTestCase.java29
11 files changed, 81 insertions, 171 deletions
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json
index 63b3990c711..c54a217d34f 100644
--- a/container-search/abi-spec.json
+++ b/container-search/abi-spec.json
@@ -5237,16 +5237,13 @@
"public java.lang.String getFormat()",
"public void setFormat(java.lang.String)",
"public java.lang.Object clone()",
+ "public boolean equals(java.lang.Object)",
+ "public int hashCode()",
"public boolean getTiming()",
"public void setTiming(boolean)",
"public java.util.Set getSummaryFields()",
- "public void setSummaryFields(java.lang.String)",
- "public boolean getTensorShortForm()",
- "public void setTensorShortForm(java.lang.String)",
- "public void setTensorShortForm(boolean)",
"public void prepare()",
- "public boolean equals(java.lang.Object)",
- "public int hashCode()"
+ "public void setSummaryFields(java.lang.String)"
],
"fields": [
"public static final java.lang.String PRESENTATION",
@@ -5254,7 +5251,6 @@
"public static final java.lang.String TIMING",
"public static final java.lang.String SUMMARY",
"public static final java.lang.String SUMMARY_FIELDS",
- "public static final java.lang.String TENSORS",
"public static final java.lang.String FORMAT"
]
},
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 1c38bb8f876..77cd4f3b292 100644
--- a/container-search/src/main/java/com/yahoo/search/Query.java
+++ b/container-search/src/main/java/com/yahoo/search/Query.java
@@ -235,18 +235,18 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
private static final Map<String, CompoundName> propertyAliases;
static {
Map<String,CompoundName> propertyAliasesBuilder = new HashMap<>();
- addAliases(Query.getArgumentType(), CompoundName.empty, propertyAliasesBuilder);
+ addAliases(Query.getArgumentType(), propertyAliasesBuilder);
+ addAliases(Ranking.getArgumentType(), propertyAliasesBuilder);
+ addAliases(Model.getArgumentType(), propertyAliasesBuilder);
+ addAliases(Presentation.getArgumentType(), propertyAliasesBuilder);
+ addAliases(Select.getArgumentType(), propertyAliasesBuilder);
propertyAliases = ImmutableMap.copyOf(propertyAliasesBuilder);
}
- private static void addAliases(QueryProfileType arguments, CompoundName prefix, Map<String, CompoundName> aliases) {
+ private static void addAliases(QueryProfileType arguments, Map<String, CompoundName> aliases) {
+ CompoundName prefix = getPrefix(arguments);
for (FieldDescription field : arguments.fields().values()) {
for (String alias : field.getAliases())
aliases.put(alias, prefix.append(field.getName()));
- if (field.getType() instanceof QueryProfileFieldType) {
- var type = ((QueryProfileFieldType) field.getType()).getQueryProfileType();
- if (type != null)
- addAliases(type, prefix.append(type.getComponentIdAsCompoundName()), aliases);
- }
}
}
@@ -1117,7 +1117,7 @@ public class Query extends com.yahoo.processing.Request implements Cloneable {
/**
* Prepares this for binary serialization.
- *
+ * <p>
* This must be invoked after all changes have been made to this query before it is passed
* on to a receiving backend. Calling it is somewhat expensive, so it should only happen once.
* If a prepared query is cloned, it stays prepared.
diff --git a/container-search/src/main/java/com/yahoo/search/query/Presentation.java b/container-search/src/main/java/com/yahoo/search/query/Presentation.java
index 31641b5c2f0..db6b07e0b0d 100644
--- a/container-search/src/main/java/com/yahoo/search/query/Presentation.java
+++ b/container-search/src/main/java/com/yahoo/search/query/Presentation.java
@@ -8,9 +8,7 @@ import com.yahoo.prelude.query.Highlight;
import com.yahoo.prelude.query.IndexedItem;
import com.yahoo.search.Query;
import com.yahoo.search.query.profile.types.FieldDescription;
-import com.yahoo.search.query.profile.types.QueryProfileFieldType;
import com.yahoo.search.query.profile.types.QueryProfileType;
-import com.yahoo.search.query.ranking.MatchPhase;
import com.yahoo.search.rendering.RendererRegistry;
import java.util.ArrayList;
@@ -32,26 +30,19 @@ public class Presentation implements Cloneable {
public static final String TIMING = "timing";
public static final String SUMMARY = "summary";
public static final String SUMMARY_FIELDS = "summaryFields";
- public static final String TENSORS = "tensors";
/** The (short) name of the parameter holding the name of the return format to use */
public static final String FORMAT = "format";
static {
- argumentType = new QueryProfileType(PRESENTATION);
+ argumentType=new QueryProfileType(PRESENTATION);
argumentType.setStrict(true);
argumentType.setBuiltin(true);
argumentType.addField(new FieldDescription(BOLDING, "boolean", "bolding"));
argumentType.addField(new FieldDescription(TIMING, "boolean", "timing"));
argumentType.addField(new FieldDescription(SUMMARY, "string", "summary"));
+ argumentType.addField(new FieldDescription(FORMAT, "string", "format template"));
argumentType.addField(new FieldDescription(SUMMARY_FIELDS, "string", "summaryFields"));
- QueryProfileType formatArgumentType = new QueryProfileType(FORMAT);
- formatArgumentType.setBuiltin(true);
- formatArgumentType.setStrict(true);
- formatArgumentType.addField(new FieldDescription("", "string", "format template"));
- formatArgumentType.addField(new FieldDescription(TENSORS, "string", "format.tensors"));
- formatArgumentType.freeze();
- argumentType.addField(new FieldDescription(FORMAT, new QueryProfileFieldType(formatArgumentType), "format"));
argumentType.freeze();
}
public static QueryProfileType getArgumentType() { return argumentType; }
@@ -62,7 +53,7 @@ public class Presentation implements Cloneable {
/** The terms to highlight in the result (only used by BoldingSearcher, may be removed later). */
private List<IndexedItem> boldingData = null;
- /** Whether to do highlighting */
+ /** Whether or not to do highlighting */
private boolean bolding = true;
/** The summary class to be shown */
@@ -74,9 +65,6 @@ public class Presentation implements Cloneable {
/** Whether optional timing data should be rendered */
private boolean timing = false;
- /** Whether to renders tensors in short form */
- private boolean tensorShortForm = false;
-
/** Set of explicitly requested summary fields, instead of summary classes */
private Set<String> summaryFields = LazySet.newHashSet();
@@ -110,10 +98,14 @@ public class Presentation implements Cloneable {
this.format = (format != null) ? format : RendererRegistry.defaultRendererId.toSpecification();
}
- /** Get the name of the format desired for result rendering. */
+ /**
+ * Get the name of the format desired for result rendering.
+ */
public String getFormat() { return format.getName(); }
- /** Set the desired format for result rendering. If null, use the default renderer. */
+ /**
+ * Set the desired format for result rendering. If null, use the default renderer.
+ */
public void setFormat(String format) {
setRenderer(ComponentSpecification.fromString(format));
}
@@ -140,7 +132,21 @@ public class Presentation implements Cloneable {
}
}
- /** Returns whether to add optional timing data to the rendered result. */
+ @Override
+ public boolean equals(Object o) {
+ if ( ! (o instanceof Presentation)) return false;
+ Presentation p = (Presentation) o;
+ return QueryHelper.equals(bolding, p.bolding) && QueryHelper.equals(summary, p.summary);
+ }
+
+ @Override
+ public int hashCode() {
+ return QueryHelper.combineHash(bolding, summary);
+ }
+
+ /**
+ * @return whether to add optional timing data to the rendered result
+ */
public boolean getTiming() {
return timing;
}
@@ -160,13 +166,20 @@ public class Presentation implements Cloneable {
return summaryFields;
}
+ /** Prepares this for binary serialization. For internal use - see {@link Query#prepare} */
+ public void prepare() {
+ if (highlight != null)
+ highlight.prepare();
+ }
+
/**
* Parse the given string as a comma delimited set of field names and
* overwrite the set of summary fields. Whitespace will be trimmed. If you
* want to add or remove fields programmatically, use
* {@link #getSummaryFields()} and modify the returned set.
*
- * @param asString the summary fields requested, e.g. "price,author,title"
+ * @param asString
+ * the summary fields requested, e.g. "price,author,title"
*/
public void setSummaryFields(String asString) {
summaryFields.clear();
@@ -176,53 +189,5 @@ public class Presentation implements Cloneable {
}
- /**
- * Returns whether tensors should use short form in JSON and textual representations, see
- * <a href="https://docs.vespa.ai/en/reference/document-json-format.html#tensor">https://docs.vespa.ai/en/reference/document-json-format.html#tensor</a>
- * and <a href="https://docs.vespa.ai/en/reference/tensor.html#tensor-literal-form">https://docs.vespa.ai/en/reference/tensor.html#tensor-literal-form</a>.
- * Default is false.
- */
- public boolean getTensorShortForm() { return tensorShortForm; }
-
- /**
- * Sets whether tensors should use short form in JSON and textual representations from a string.
- *
- * @param value a string which must be either 'short' or 'long'
- * @throws IllegalArgumentException if any other value is passed
- */
- public void setTensorShortForm(String value) {
- tensorShortForm = toTensorShortForm(value);
- }
-
- private boolean toTensorShortForm(String value) {
- switch (value) {
- case "short": return true;
- case "long": return false;
- default: throw new IllegalArgumentException("Value must be 'long' or 'short', not '" + value + "'");
- }
- }
-
- public void setTensorShortForm(boolean tensorShortForm) {
- this.tensorShortForm = tensorShortForm;
- }
-
- /** Prepares this for binary serialization. For internal use - see {@link Query#prepare} */
- public void prepare() {
- if (highlight != null)
- highlight.prepare();
- }
-
- @Override
- public boolean equals(Object o) {
- if ( ! (o instanceof Presentation)) return false;
- Presentation p = (Presentation) o;
- return QueryHelper.equals(bolding, p.bolding) && QueryHelper.equals(summary, p.summary);
- }
-
- @Override
- public int hashCode() {
- return QueryHelper.combineHash(bolding, summary);
- }
-
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
index a0f38f61672..1d6f584bfaa 100644
--- a/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
+++ b/container-search/src/main/java/com/yahoo/search/query/profile/types/FieldDescription.java
@@ -81,7 +81,7 @@ public class FieldDescription implements Comparable<FieldDescription> {
/**
* Creates a field description
*
- * @param name the name of the field, empty means it describes the value held by the query profile itself
+ * @param name the name of the field
* @param type the type of the field represented as a string - see {@link com.yahoo.search.query.profile.types.FieldType}
* @param aliases a list of aliases, never null. Aliases are not following dotted
* (meaning they are global, not that they cannot contain dots) and are case insensitive.
@@ -89,6 +89,8 @@ public class FieldDescription implements Comparable<FieldDescription> {
* @param overridable whether this can be overridden when first set in a profile. Default: true
*/
public FieldDescription(CompoundName name, FieldType type, List<String> aliases, boolean mandatory, boolean overridable) {
+ if (name.isEmpty())
+ throw new IllegalArgumentException("Illegal name ''");
for (String nameComponent : name.asList())
QueryProfile.validateName(nameComponent);
this.name = name;
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/PropertyAliases.java b/container-search/src/main/java/com/yahoo/search/query/properties/PropertyAliases.java
index 1b036b96e01..87f39b88981 100644
--- a/container-search/src/main/java/com/yahoo/search/query/properties/PropertyAliases.java
+++ b/container-search/src/main/java/com/yahoo/search/query/properties/PropertyAliases.java
@@ -38,6 +38,7 @@ public class PropertyAliases extends Properties {
*/
protected CompoundName unalias(CompoundName nameOrAlias) {
if (aliases.isEmpty()) return nameOrAlias;
+ if (nameOrAlias.size() > 1) return nameOrAlias; // aliases are simple names
CompoundName properName = aliases.get(nameOrAlias.getLowerCasedName());
return (properName != null) ? properName : nameOrAlias;
}
diff --git a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
index 243915662d2..9a09c23b23b 100644
--- a/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
+++ b/container-search/src/main/java/com/yahoo/search/query/properties/QueryProperties.java
@@ -122,16 +122,12 @@ public class QueryProperties extends Properties {
if (key.last().equals(Select.GROUPING)) return query.getSelect().getGroupingString();
}
}
- else if (key.first().equals(Presentation.PRESENTATION)) {
- if (key.size() == 2) {
- if (key.last().equals(Presentation.BOLDING)) return query.getPresentation().getBolding();
- if (key.last().equals(Presentation.SUMMARY)) return query.getPresentation().getSummary();
- if (key.last().equals(Presentation.FORMAT)) return query.getPresentation().getFormat();
- if (key.last().equals(Presentation.TIMING)) return query.getPresentation().getTiming();
- if (key.last().equals(Presentation.SUMMARY_FIELDS)) return query.getPresentation().getSummaryFields();
- } else if (key.size() == 3 && key.get(1).equals(Presentation.FORMAT)) {
- if (key.last().equals(Presentation.TENSORS)) return query.getPresentation().getTensorShortForm();
- }
+ else if (key.size() == 2 && key.first().equals(Presentation.PRESENTATION)) {
+ if (key.last().equals(Presentation.BOLDING)) return query.getPresentation().getBolding();
+ if (key.last().equals(Presentation.SUMMARY)) return query.getPresentation().getSummary();
+ if (key.last().equals(Presentation.FORMAT)) return query.getPresentation().getFormat();
+ if (key.last().equals(Presentation.TIMING)) return query.getPresentation().getTiming();
+ if (key.last().equals(Presentation.SUMMARY_FIELDS)) return query.getPresentation().getSummaryFields();
}
else if (key.first().equals("rankfeature") || key.first().equals("featureoverride")) { // featureoverride is deprecated
return query.getRanking().getFeatures().getObject(key.rest().toString());
@@ -277,27 +273,17 @@ public class QueryProperties extends Properties {
throwIllegalParameter(key.rest().toString(), Ranking.RANKING);
}
}
- else if (key.first().equals(Presentation.PRESENTATION)) {
- if (key.size() == 2) {
- if (key.last().equals(Presentation.BOLDING))
- query.getPresentation().setBolding(asBoolean(value, true));
- else if (key.last().equals(Presentation.SUMMARY))
- query.getPresentation().setSummary(asString(value, ""));
- else if (key.last().equals(Presentation.FORMAT))
- query.getPresentation().setFormat(asString(value, ""));
- else if (key.last().equals(Presentation.TIMING))
- query.getPresentation().setTiming(asBoolean(value, true));
- else if (key.last().equals(Presentation.SUMMARY_FIELDS))
- query.getPresentation().setSummaryFields(asString(value, ""));
- else
- throwIllegalParameter(key.last(), Presentation.PRESENTATION);
- }
- else if (key.size() == 3 && key.get(1).equals(Presentation.FORMAT)) {
- if (key.last().equals(Presentation.TENSORS))
- query.getPresentation().setTensorShortForm(asString(value, ""));
- else
- throwIllegalParameter(key.last(), Presentation.FORMAT);
- }
+ else if (key.size() == 2 && key.first().equals(Presentation.PRESENTATION)) {
+ if (key.last().equals(Presentation.BOLDING))
+ query.getPresentation().setBolding(asBoolean(value, true));
+ else if (key.last().equals(Presentation.SUMMARY))
+ query.getPresentation().setSummary(asString(value, ""));
+ else if (key.last().equals(Presentation.FORMAT))
+ query.getPresentation().setFormat(asString(value,""));
+ else if (key.last().equals(Presentation.TIMING))
+ query.getPresentation().setTiming(asBoolean(value, true));
+ else if (key.last().equals(Presentation.SUMMARY_FIELDS))
+ query.getPresentation().setSummaryFields(asString(value,""));
else
throwIllegalParameter(key.last(), Presentation.PRESENTATION);
}
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
index 8e8e687076f..f9a91558254 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
@@ -79,6 +79,7 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
private static final CompoundName WRAP_ALL_MAPS = new CompoundName("renderer.json.jsonMaps");
private static final CompoundName DEBUG_RENDERING_KEY = new CompoundName("renderer.json.debug");
private static final CompoundName JSON_CALLBACK = new CompoundName("jsoncallback");
+ private static final CompoundName TENSOR_FORMAT = new CompoundName("format.tensors");
// if this must be optimized, simply use com.fasterxml.jackson.core.SerializableString
private static final String BUCKET_LIMITS = "limits";
@@ -172,8 +173,7 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
beginJsonCallback(stream);
debugRendering = getDebugRendering(getResult().getQuery());
jsonMaps = getWrapAllMaps(getResult().getQuery());
- tensorShortFormRendering = getResult().getQuery() != null
- && getResult().getQuery().getPresentation().getTensorShortForm();
+ tensorShortFormRendering = getTensorShortFormRendering(getResult().getQuery());
setGenerator(generatorFactory.createGenerator(stream, JsonEncoding.UTF8), debugRendering);
renderedChildren = new ArrayDeque<>();
generator.writeStartObject();
@@ -212,6 +212,12 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
return q != null && q.properties().getBoolean(DEBUG_RENDERING_KEY, false);
}
+ private boolean getTensorShortFormRendering(Query q) {
+ if (q == null || q.properties().get(TENSOR_FORMAT) == null)
+ return false;
+ return q.properties().getString(TENSOR_FORMAT).equalsIgnoreCase("short");
+ }
+
protected void renderTrace(Trace trace) throws IOException {
if (!trace.traceNode().children().iterator().hasNext()) return;
if (getResult().getQuery().getTraceLevel() == 0) return;
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 3ed044601f0..60b6c6dbe84 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
@@ -11,7 +11,7 @@ import static org.junit.Assert.assertTrue;
*/
public class DumpToolTestCase {
- private final String profileDir = "src/test/java/com/yahoo/search/query/profile/config/test/multiprofile";
+ private String profileDir = "src/test/java/com/yahoo/search/query/profile/config/test/multiprofile";
@Test
public void testNoParameters() {
@@ -25,13 +25,12 @@ public class DumpToolTestCase {
@Test
public void testNoDimensionValues() {
- System.out.println(new DumpTool().resolveAndDump("multiprofile1", profileDir));
- assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir).contains("a=general-a\n"));
+ assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir).startsWith("a=general-a\n"));
}
@Test
public void testAllParametersSet() {
- assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir, "").contains("a=general-a\n"));
+ assertTrue(new DumpTool().resolveAndDump("multiprofile1", profileDir, "").startsWith("a=general-a\n"));
}
@Test
diff --git a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
index fa7508ea5ac..4b8edfdde73 100644
--- a/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/query/profile/types/test/NameTestCase.java
@@ -47,6 +47,7 @@ public class NameTestCase {
assertLegalFieldName("a/b");
assertLegalFieldName("/a/b");
assertLegalFieldName("/a/b/");
+ assertIllegalFieldName("");
assertIllegalFieldName("aBc.dooEee.ce_d.-some-other.moreHere",
"Could not set 'aBc.dooEee.ce_d.-some-other.moreHere' to 'anyValue'",
"Illegal name '-some-other'");
diff --git a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
index 95ef4ec3051..f3a71af0b9e 100644
--- a/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
+++ b/container-search/src/test/java/com/yahoo/search/rendering/JsonRendererTestCase.java
@@ -54,7 +54,6 @@ import com.yahoo.tensor.Tensor;
import com.yahoo.tensor.TensorType;
import com.yahoo.tensor.serialization.TypedBinaryFormat;
import com.yahoo.text.Utf8;
-import com.yahoo.yolean.Exceptions;
import com.yahoo.yolean.trace.TraceNode;
import org.junit.Before;
import org.junit.Test;
@@ -70,7 +69,6 @@ import java.util.concurrent.ExecutionException;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
/**
* Functional testing of {@link JsonRenderer}.
@@ -167,26 +165,11 @@ public class JsonRendererTestCase {
h.setField("tensor_mixed", new TensorFieldValue(Tensor.from("tensor(x{},y[2]):{a:[1,2], b:[3,4]}")));
h.setField("summaryfeatures", summaryFeatures);
- Result result1 = new Result(new Query("/?presentation.format.tensors=short"));
- result1.hits().add(h);
- result1.setTotalHitCount(1L);
- String summary1 = render(result1);
- assertEqualJson(expected, summary1);
-
- Result result2 = new Result(new Query("/?format.tensors=short"));
- result2.hits().add(h);
- result2.setTotalHitCount(1L);
- String summary2 = render(result2);
- assertEqualJson(expected, summary2);
-
- try {
- render(new Result(new Query("/?presentation.format.tensors=unknown")));
- fail("Expected exception");
- }
- catch (IllegalArgumentException e) {
- assertEquals("Could not set 'presentation.format.tensors' to 'unknown': Value must be 'long' or 'short', not 'unknown'",
- Exceptions.toMessageString(e));
- }
+ Result r = new Result(new Query("/?format.tensors=short"));
+ r.hits().add(h);
+ r.setTotalHitCount(1L);
+ String summary = render(r);
+ assertEqualJson(expected, summary);
}
@Test
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 3b0a0ad7972..312fe175270 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
@@ -1092,35 +1092,6 @@ public class QueryTestCase {
query.getSelect().getGrouping().toString());
}
- /**
- * Tests that the value presentation.format.tensors can be set in a query profile.
- * This is special because presentation.format is a native query profile.
- */
- @Test
- public void testSettingNativeQueryProfileValueInQueryProfile() {
- {
- QueryProfileRegistry registry = new QueryProfileRegistry();
- QueryProfile profile = new QueryProfile("default");
- profile.set("presentation.format.tensors", "short", Map.of(), registry);
- registry.register(profile);
- CompiledQueryProfileRegistry cRegistry = registry.compile();
- Query query = new Query("?query=foo", cRegistry.findQueryProfile("default"));
- assertTrue(query.getPresentation().getTensorShortForm());
- }
-
- { // Same as above but also set presentation.format
- QueryProfileRegistry registry = new QueryProfileRegistry();
- QueryProfile profile = new QueryProfile("default");
- profile.set("presentation.format", "xml", Map.of(), registry);
- profile.set("presentation.format.tensors", "short", Map.of(), registry);
- registry.register(profile);
- CompiledQueryProfileRegistry cRegistry = registry.compile();
- Query query = new Query("?query=foo", cRegistry.findQueryProfile("default"));
- assertEquals("xml", query.getPresentation().getFormat());
- assertTrue(query.getPresentation().getTensorShortForm());
- }
- }
-
private void assertDetectionText(String expectedDetectionText, String queryString, String ... indexSpecs) {
Query q = new Query(httpEncode("/?query=" + queryString));
SearchDefinition sd = new SearchDefinition("testSearchDefinition");