use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testIncompatibleDimensionsSimplified.
public void testIncompatibleDimensionsSimplified() {
QueryProfile alert = new QueryProfile("alert");
QueryProfile backendBase = new QueryProfile("backendBase");
backendBase.set("custid", "s", (QueryProfileRegistry) null);
QueryProfile backend = new QueryProfile("backend");
backend.setDimensions(new String[] { "sort", "lang", "fr", "entry" });
backend.set("custid", "yahoo/alerts", new String[] { null, "en-US", null, "alert" }, null);
backend.addInherited(backendBase);
QueryProfile web = new QueryProfile("web");
web.setDimensions(new String[] { "entry", "recency" });
web.set("fr", "alerts", new String[] { "alert" }, null);
alert.set("vertical", backend, (QueryProfileRegistry) null);
alert.set("multimedia", web, (QueryProfileRegistry) null);
CompiledQueryProfile cAlert = alert.compile(null);
assertEquals("yahoo/alerts", cAlert.get("vertical.custid", toMap("entry=alert", "intl=us", "lang=en-US")));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testSimple.
public void testSimple() {
QueryProfile profile = new QueryProfile("a");
profile.set("a", "a.deflt", (QueryProfileRegistry) null);
profile.setDimensions(new String[] { "x", "y", "z" });
profile.set("a", "a.1.*.*", new String[] { "x1", null, null }, null);
profile.set("a", "a.1.*.1", new String[] { "x1", null, "z1" }, null);
profile.set("a", "a.1.*.5", new String[] { "x1", null, "z5" }, null);
profile.set("a", "a.1.1.*", new String[] { "x1", "y1", null }, null);
profile.set("a", "a.1.5.*", new String[] { "x1", "y5", null }, null);
profile.set("a", "a.1.1.1", new String[] { "x1", "y1", "z1" }, null);
profile.set("a", "a.2.1.1", new String[] { "x2", "y1", "z1" }, null);
profile.set("a", "a.1.2.2", new String[] { "x1", "y2", "z2" }, null);
profile.set("a", "a.1.2.3", new String[] { "x1", "y2", "z3" }, null);
// Same as ,null,null
profile.set("a", "a.2.*.*", new String[] { "x2" }, null);
CompiledQueryProfile cprofile = profile.compile(null);
// Perfect matches
assertGet("a.deflt", "a", new String[] { null, null, null }, profile, cprofile);
assertGet("a.1.*.*", "a", new String[] { "x1", null, null }, profile, cprofile);
assertGet("a.1.1.*", "a", new String[] { "x1", "y1", null }, profile, cprofile);
assertGet("a.1.5.*", "a", new String[] { "x1", "y5", null }, profile, cprofile);
assertGet("a.1.*.1", "a", new String[] { "x1", null, "z1" }, profile, cprofile);
assertGet("a.1.*.5", "a", new String[] { "x1", null, "z5" }, profile, cprofile);
assertGet("a.1.1.1", "a", new String[] { "x1", "y1", "z1" }, profile, cprofile);
assertGet("a.2.1.1", "a", new String[] { "x2", "y1", "z1" }, profile, cprofile);
assertGet("a.1.2.2", "a", new String[] { "x1", "y2", "z2" }, profile, cprofile);
assertGet("a.1.2.3", "a", new String[] { "x1", "y2", "z3" }, profile, cprofile);
assertGet("a.2.*.*", "a", new String[] { "x2", null, null }, profile, cprofile);
// Wildcard matches
assertGet("a.deflt", "a", new String[] { "x?", "y?", "z?" }, profile, cprofile);
assertGet("a.deflt", "a", new String[] { "x?", "y1", "z1" }, profile, cprofile);
assertGet("a.1.*.*", "a", new String[] { "x1", "y?", "z?" }, profile, cprofile);
assertGet("a.1.*.*", "a", new String[] { "x1", "y?", "z?" }, profile, cprofile);
assertGet("a.1.1.*", "a", new String[] { "x1", "y1", "z?" }, profile, cprofile);
assertGet("a.1.*.1", "a", new String[] { "x1", "y?", "z1" }, profile, cprofile);
assertGet("a.1.5.*", "a", new String[] { "x1", "y5", "z?" }, profile, cprofile);
assertGet("a.1.*.5", "a", new String[] { "x1", "y?", "z5" }, profile, cprofile);
// Left dimension gets precedence
assertGet("a.1.5.*", "a", new String[] { "x1", "y5", "z5" }, profile, cprofile);
assertGet("a.2.*.*", "a", new String[] { "x2", "y?", "z?" }, profile, cprofile);
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testVariantInheritanceOverridesBaseInheritanceMixed.
public void testVariantInheritanceOverridesBaseInheritanceMixed() {
QueryProfile root = new QueryProfile("root");
root.set("model.defaultIndex", "default", (QueryProfileRegistry) null);
QueryProfile multi = new QueryProfile("multi");
multi.setDimensions(new String[] { "x" });
multi.set("model.defaultIndex", "title", (QueryProfileRegistry) null);
multi.set("model.queryString", "modelQuery", (QueryProfileRegistry) null);
multi.addInherited(root, new String[] { "x1" });
multi.set("model.queryString", "modelVariantQuery", new String[] { "x1" }, null);
CompiledQueryProfile cmulti = multi.compile(null);
assertEquals("default", cmulti.get("model.defaultIndex", toMap("x=x1")));
assertEquals("modelVariantQuery", cmulti.get("model.queryString", toMap("x=x1")));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileVariantsCloneTestCase method test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning.
/**
* Test for Ticket 4882480.
*/
@Test
public void test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning() {
Map<String, String> dimensionBinding = createDimensionBinding("location", "norway");
QueryProfile profile = new QueryProfile("profile");
profile.setDimensions(keys(dimensionBinding));
DimensionValues dimensionValues = DimensionValues.createFrom(values(dimensionBinding));
profile.set("interior.leaf", "leafValue", dimensionValues, null);
profile.set("interior", "interiorValue", dimensionValues, null);
CompiledQueryProfile clone = profile.compile(null).clone();
assertEquals(profile.get("interior", dimensionBinding, null), clone.get("interior", dimensionBinding));
assertEquals(profile.get("interior.leaf", dimensionBinding, null), clone.get("interior.leaf", dimensionBinding));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile in project vespa by vespa-engine.
the class QueryProfileTypeTestCase method testTypedAssignmentOfQueryProfilesNonStrict.
/**
* Tests assigning a subprofile directly
*/
public void testTypedAssignmentOfQueryProfilesNonStrict() {
QueryProfile profile = new QueryProfile("test");
profile.setType(type);
QueryProfile map1 = new QueryProfile("myMap1");
map1.set("key1", "value1", registry);
QueryProfile map2 = new QueryProfile("myMap2");
map2.set("key2", "value2", registry);
QueryProfile myUser = new QueryProfile("myUser");
myUser.setType(user);
myUser.set("myUserString", "userValue1", registry);
myUser.set("myUserInteger", 442, registry);
assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
profile.set("myQueryProfile", map1, registry);
// Legal because this is not strict
profile.set("someMap", map2, registry);
assertWrongType(profile, "reference to a query profile of type 'user'", "myUserQueryProfile", map1);
profile.set("myUserQueryProfile", myUser, registry);
CompiledQueryProfile cprofile = profile.compile(null);
assertEquals("value1", cprofile.get("myQueryProfile.key1"));
assertEquals("value2", cprofile.get("someMap.key2"));
assertEquals("userValue1", cprofile.get("myUserQueryProfile.myUserString"));
assertEquals(442, cprofile.get("myUserQueryProfile.myUserInteger"));
}
Aggregations