use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.
the class XmlReadingTestCase method testVersions.
@Test
public void testVersions() {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/versions");
registry.freeze();
assertEquals("1.20.100", registry.findQueryProfile("testprofile:1.20.100").getId().getVersion().toString());
assertEquals("1.20.100", registry.findQueryProfile("testprofile:1.20").getId().getVersion().toString());
assertEquals("1.20.100", registry.findQueryProfile("testprofile:1").getId().getVersion().toString());
assertEquals("1.20.100", registry.findQueryProfile("testprofile").getId().getVersion().toString());
}
use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.
the class QueryProfileVariantsTestCase method testConfigCreation2.
@Test
public void testConfigCreation2() throws IOException {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/vespa/model/container/search/test/queryprofilevariants2");
QueryProfiles profiles = new QueryProfiles(registry);
assertSerializedConfigFileEquals(root + "query-profile-variants2-configuration.cfg", profiles.getConfig().toString());
}
use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.
the class XmlReadingTestCase method testKlee.
@Test
public void testKlee() {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/klee");
QueryProfile pv = registry.getComponent("twitter_dd-us:0.2.4");
assertEquals("0.2.4", pv.getId().getVersion().toString());
assertEquals("[query profile 'production']", pv.inherited().toString());
QueryProfile p = registry.getComponent("twitter_dd-us:0.0.0");
// that is 0.0.0
assertEquals("", p.getId().getVersion().toString());
assertEquals("[query profile 'twitter_dd']", p.inherited().toString());
}
use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.
the class MultiProfileTestCase method testValid.
public void testValid() {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/multiprofile");
QueryProfile multiprofile1 = registry.getComponent("multiprofile1");
assertNotNull(multiprofile1);
assertGet("general-a", "a", new String[] { null, null, null }, multiprofile1);
assertGet("us-nokia-test1-a", "a", new String[] { "us", "nok ia", "test1" }, multiprofile1);
assertGet("us-nokia-b", "b", new String[] { "us", "nok ia", "test1" }, multiprofile1);
assertGet("us-a", "a", new String[] { "us", null, null }, multiprofile1);
assertGet("us-b", "b", new String[] { "us", null, null }, multiprofile1);
assertGet("us-nokia-a", "a", new String[] { "us", "nok ia", null }, multiprofile1);
assertGet("us-test1-a", "a", new String[] { "us", null, "test1" }, multiprofile1);
assertGet("us-test1-b", "b", new String[] { "us", null, "test1" }, multiprofile1);
assertGet("us-a", "a", new String[] { "us", "unspecified", "unspecified" }, multiprofile1);
assertGet("us-nokia-a", "a", new String[] { "us", "nok ia", "unspecified" }, multiprofile1);
assertGet("us-test1-a", "a", new String[] { "us", "unspecified", "test1" }, multiprofile1);
assertGet("us-nokia-b", "b", new String[] { "us", "nok ia", "test1" }, multiprofile1);
// ...inherited
assertGet("parent1-value", "parent1", new String[] { "us", "nok ia", "-" }, multiprofile1);
assertGet("parent2-value", "parent2", new String[] { "us", "nok ia", "-" }, multiprofile1);
assertGet(null, "parent1", new String[] { "us", "-", "-" }, multiprofile1);
assertGet(null, "parent2", new String[] { "us", "-", "-" }, multiprofile1);
}
use of com.yahoo.search.query.profile.config.QueryProfileXMLReader in project vespa by vespa-engine.
the class XmlReadingTestCase method testValid.
@Test
public void testValid() {
QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/validxml");
CompiledQueryProfileRegistry cRegistry = registry.compile();
QueryProfileType rootType = registry.getType("rootType");
assertEquals(1, rootType.inherited().size());
assertEquals("native", rootType.inherited().get(0).getId().getName());
assertTrue(rootType.isStrict());
assertTrue(rootType.getMatchAsPath());
FieldDescription timeField = rootType.getField("time");
assertTrue(timeField.isMandatory());
assertEquals("long", timeField.getType().toInstanceDescription());
FieldDescription userField = rootType.getField("user");
assertFalse(userField.isMandatory());
assertEquals("reference to a query profile of type 'user'", userField.getType().toInstanceDescription());
QueryProfileType user = registry.getType("user");
assertEquals(0, user.inherited().size());
assertFalse(user.isStrict());
assertFalse(user.getMatchAsPath());
assertTrue(userField.isOverridable());
FieldDescription ageField = user.getField("age");
assertTrue(ageField.isMandatory());
assertEquals("integer", ageField.getType().toInstanceDescription());
FieldDescription robotField = user.getField("robot");
assertFalse(robotField.isMandatory());
assertFalse(robotField.isOverridable());
assertEquals("boolean", robotField.getType().toInstanceDescription());
CompiledQueryProfile defaultProfile = cRegistry.getComponent("default");
assertNull(defaultProfile.getType());
assertEquals("20", defaultProfile.get("hits"));
assertFalse(defaultProfile.isOverridable(new CompoundName("hits"), null));
assertFalse(defaultProfile.isOverridable(new CompoundName("user.trusted"), null));
assertEquals("false", defaultProfile.get("user.trusted"));
CompiledQueryProfile referencingProfile = cRegistry.getComponent("referencingModelSettings");
assertNull(referencingProfile.getType());
assertEquals("some query", referencingProfile.get("model.queryString"));
assertEquals("aDefaultIndex", referencingProfile.get("model.defaultIndex"));
// Request parameters here should be ignored
HttpRequest request = HttpRequest.createTestRequest("?query=foo&user.trusted=true&default-index=title", Method.GET);
Query query = new Query(request, defaultProfile);
assertEquals("false", query.properties().get("user.trusted"));
assertEquals("default", query.getModel().getDefaultIndex());
assertEquals("default", query.properties().get("default-index"));
CompiledQueryProfile rootProfile = cRegistry.getComponent("root");
assertEquals("rootType", rootProfile.getType().getId().getName());
assertEquals(30, rootProfile.get("hits"));
assertEquals(3, rootProfile.get("traceLevel"));
assertTrue(rootProfile.isOverridable(new CompoundName("hits"), null));
QueryProfile someUser = registry.getComponent("someUser");
assertEquals("5", someUser.get("sub.test"));
assertEquals(18, someUser.get("age"));
// aliases
assertEquals(18, someUser.get("alder"));
assertEquals(18, someUser.get("anno"));
assertEquals(18, someUser.get("aLdER"));
assertEquals(18, someUser.get("ANNO"));
// Only aliases are case insensitive
assertNull(someUser.get("Age"));
Map<String, String> context = new HashMap<>();
context.put("x", "x1");
assertEquals(37, someUser.get("alder", context, null));
assertEquals(37, someUser.get("anno", context, null));
assertEquals(37, someUser.get("aLdER", context, null));
assertEquals(37, someUser.get("ANNO", context, null));
assertEquals("male", someUser.get("gender", context, null));
assertEquals("male", someUser.get("sex", context, null));
assertEquals("male", someUser.get("Sex", context, null));
// Only aliases are case insensitive
assertNull(someUser.get("Gender", context, null));
}
Aggregations