use of com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry in project vespa by vespa-engine.
the class XmlReadingTestCase method testNewsFE2.
@Test
public void testNewsFE2() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe2").compile();
String queryString = "tiled?query=a&intl=tw&mode=adv&mode=adv";
Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
assertEquals("news_adv", query.properties().listProperties().get("provider"));
assertEquals("news_adv", query.properties().get("provider"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry in project vespa by vespa-engine.
the class XmlReadingTestCase method testNewsCase4.
// Should cause an exception on the first line as we are trying to create a profile setting an illegal value in "ranking"
@Test
public void testNewsCase4() {
CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase4").compile();
Query query;
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET), registry.getComponent("default"));
assertEquals("0.0", query.properties().get("ranking.features"));
query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET), registry.getComponent("default"));
assertEquals("0.1", query.properties().get("ranking.features"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry in project vespa by vespa-engine.
the class QueryProfileTypeTestCase method testSettingValueInStrictTypeNestedUnderUntypedMaps.
/**
* Tests setting a illegal value in a strict profile nested under untyped maps
*/
public void testSettingValueInStrictTypeNestedUnderUntypedMaps() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
topMap.set("subMap", subMap, registry);
QueryProfile test = new QueryProfile("test");
test.setType(typeStrict);
subMap.set("typeProfile", test, registry);
registry.register(topMap);
registry.register(subMap);
registry.register(test);
CompiledQueryProfileRegistry cRegistry = registry.compile();
try {
new Query(HttpRequest.createTestRequest("?subMap.typeProfile.someValue=value", com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("topMap"));
fail("Above statement should throw");
} catch (QueryException e) {
// As expected.
assertThat(Exceptions.toMessageString(e), containsString("Could not set 'subMap.typeProfile.someValue' to 'value': 'someValue' is not declared in query profile type 'testtypeStrict', and the type is strict"));
}
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry in project vespa by vespa-engine.
the class QueryProfileTypeTestCase method testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile.
/**
* Tests overriding a subprofile as an id string through the query.
* Here, no user profile is set before it is assigned in the query
* The whole thing is accessed through a two levels of nontyped top-level profiles
*/
public void testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
QueryProfile topMap = new QueryProfile("topMap");
QueryProfile subMap = new QueryProfile("topSubMap");
topMap.set("subMap", subMap, registry);
QueryProfile test = new QueryProfile("test");
test.setType(type);
subMap.set("typeProfile", test, registry);
QueryProfile newUser = new QueryProfile("newUser");
newUser.setType(user);
newUser.set("myUserString", "newUserValue1", registry);
newUser.set("myUserInteger", 845, registry);
registry.register(topMap);
registry.register(subMap);
registry.register(test);
registry.register(newUser);
CompiledQueryProfileRegistry cRegistry = registry.compile();
Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myUserQueryProfile=newUser", com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("topMap"));
assertEquals(0, query.errors().size());
assertEquals("newUserValue1", query.properties().get("subMap.typeProfile.myUserQueryProfile.myUserString"));
assertEquals(845, query.properties().get("subMap.typeProfile.myUserQueryProfile.myUserInteger"));
}
use of com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry in project vespa by vespa-engine.
the class QueryProfileTypeTestCase method testTensorRankFeatureInRequest.
public void testTensorRankFeatureInRequest() throws UnsupportedEncodingException {
QueryProfile profile = new QueryProfile("test");
profile.setType(type);
registry.register(profile);
CompiledQueryProfileRegistry cRegistry = registry.compile();
String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
Query query = new Query(HttpRequest.createTestRequest("?" + encode("ranking.features.query(myTensor1)") + "=" + encode(tensorString), com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("test"));
assertEquals(0, query.errors().size());
assertEquals(Tensor.from(tensorString), query.properties().get("ranking.features.query(myTensor1)"));
assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
Aggregations