use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testQueryProfileModelValueListing.
public void testQueryProfileModelValueListing() {
QueryProfile p = new QueryProfile("test");
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=bar", Method.GET), p.compile(null));
assertEquals("bar", q.properties().get("model.queryString"));
assertEquals("bar", q.properties().listProperties().get("model.queryString"));
q.getModel().setQueryString("baz");
assertEquals("baz", q.properties().get("model.queryString"));
// Is still bar because model variables are not supported with the list function
assertEquals("bar", q.properties().listProperties().get("model.queryString"));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testSettingNonLeaf4b.
public void testSettingNonLeaf4b() {
QueryProfile p = new QueryProfile("test");
p.setDimensions(new String[] { "x" });
p.set("a", "a-value", (QueryProfileRegistry) null);
p.set("a.b", "a.b-value", new String[] { "x1" }, null);
QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
assertEquals("a-value", cp.get("a"));
assertNull(cp.get("a.b"));
assertEquals("a-value", cp.get("a", new String[] { "x1" }));
assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, new String[] { "x1" })));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testExplicitReferenceOverride.
/**
* Tests having both an explicit reference and an override
*/
public void testExplicitReferenceOverride() {
QueryProfile a1 = new QueryProfile("a1");
a1.set("b", "a1.b", (QueryProfileRegistry) null);
QueryProfile profile = new QueryProfile("test");
profile.set("a", a1, (QueryProfileRegistry) null);
profile.set("a.b", "a.b", (QueryProfileRegistry) null);
assertEquals("a.b", profile.compile(null).get("a.b"));
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testBasics.
public void testBasics() {
QueryProfile profile = new QueryProfile("test");
profile.set("a", "a-value", (QueryProfileRegistry) null);
profile.set("b.c", "b.c-value", (QueryProfileRegistry) null);
profile.set("d.e.f", "d.e.f-value", (QueryProfileRegistry) null);
CompiledQueryProfile cprofile = profile.compile(null);
assertEquals("a-value", cprofile.get("a"));
assertEquals("b.c-value", cprofile.get("b.c"));
assertEquals("d.e.f-value", cprofile.get("d.e.f"));
assertNull(cprofile.get("nonexistent"));
assertNull(cprofile.get("nested.nonexistent"));
assertTrue(profile.lookup("b", null).getClass() == QueryProfile.class);
assertTrue(profile.lookup("b", null).getClass() == QueryProfile.class);
}
use of com.yahoo.search.query.profile.QueryProfile in project vespa by vespa-engine.
the class QueryProfileTestCase method testQueryProfileInlineValueReassignmentSimpleName.
public void testQueryProfileInlineValueReassignmentSimpleName() {
QueryProfile p = new QueryProfile("test");
p.set("key", "%{model.queryString}", (QueryProfileRegistry) null);
p.freeze();
Query q = new Query(HttpRequest.createTestRequest("?query=foo", Method.GET), p.compile(null));
assertEquals("foo", q.properties().get("key"));
assertEquals("foo", q.properties().listProperties().get("key"));
q.getModel().setQueryString("bar");
assertEquals("bar", q.properties().get("key"));
// Is still bar because model variables are not supported with the list function
assertEquals("foo", q.properties().listProperties().get("key"));
}
Aggregations