use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class ParametersTestCase method createProfile.
public CompiledQueryProfile createProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile profile = new QueryProfile("test");
profile.set("model.filter", "+year:2001", registry);
profile.set("model.language", "en", registry);
return registry.compile().findQueryProfile("test");
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class OverrideTestCase method testUntypedNestedUnoverridable.
/**
* Check that non-overridables are protected also in nested untyped references
*/
public void testUntypedNestedUnoverridable() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile topMap = new QueryProfile("topMap");
registry.register(topMap);
QueryProfile subMap = new QueryProfile("topSubMap");
topMap.set("subMap", subMap, registry);
registry.register(subMap);
QueryProfile test = new QueryProfile("test");
test.setType(type);
subMap.set("test", test, registry);
registry.register(test);
QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
myUser.set("myUserString", "finalValue", registry);
test.set("myUserQueryProfile", myUser, registry);
registry.register(myUser);
registry.freeze();
Query query = new Query(HttpRequest.createTestRequest("?subMap.test.myUserQueryProfile.myUserString=newValue", Method.GET), registry.compile().getComponent("topMap"));
assertEquals(0, query.errors().size());
assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
query.properties().set("subMap.test.myUserQueryProfile.myUserString", "newValue");
assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class OverrideTestCase method testInheritedNonOverridableInType.
/**
* Tests overridability in an inherited field
*/
public void testInheritedNonOverridableInType() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
test.set("myString", "finalString", (QueryProfileRegistry) null);
registry.register(test);
QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
registry.freeze();
Query query = new Query(HttpRequest.createTestRequest("?myString=newString", Method.GET), registry.compile().getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals("finalString", query.properties().get("myString"));
query.properties().set("myString", "newString");
assertEquals("finalString", query.properties().get("myString"));
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class OverrideTestCase method testUnoverridableQueryProfile.
/**
* Check that a query profile cannot be overridden
*/
public void testUnoverridableQueryProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
registry.register(test);
QueryProfile myUser = new QueryProfile("user");
myUser.setType(user);
myUser.set("myUserInteger", 1, registry);
myUser.set("myUserString", "userValue", registry);
test.set("myUserQueryProfile", myUser, registry);
registry.register(myUser);
QueryProfile otherUser = new QueryProfile("otherUser");
otherUser.setType(user);
otherUser.set("myUserInteger", 2, registry);
registry.register(otherUser);
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?myUserQueryprofile=otherUser", Method.GET), cRegistry.getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(1, query.properties().get("myUserQueryProfile.myUserInteger"));
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class OverrideTestCase method testInheritedNonOverridableInProfile.
/**
* Tests overridability in an inherited field
*/
public void testInheritedNonOverridableInProfile() {
QueryProfileRegistry registry = new QueryProfileRegistry();
QueryProfile test = new QueryProfile("test");
test.setType(type);
test.set("myInteger", 1, registry);
test.setOverridable("myInteger", false, null);
registry.register(test);
QueryProfile profile = new QueryProfile("profile");
profile.addInherited(test);
registry.register(profile);
registry.freeze();
Query query = new Query(HttpRequest.createTestRequest("?myInteger=32", Method.GET), registry.compile().getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(1, query.properties().get("myInteger"));
query.properties().set("myInteger", 32);
assertEquals(1, query.properties().get("myInteger"));
}
Aggregations