Search in sources :

Example 11 with QueryProfileXMLReader

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());
}
Also used : QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 12 with QueryProfileXMLReader

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());
}
Also used : QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 13 with QueryProfileXMLReader

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());
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 14 with QueryProfileXMLReader

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);
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader)

Example 15 with QueryProfileXMLReader

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));
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) CompoundName(com.yahoo.processing.request.CompoundName) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query) HashMap(java.util.HashMap) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) Test(org.junit.Test)

Aggregations

QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)23 Test (org.junit.Test)21 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)14 Query (com.yahoo.search.Query)13 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)5 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)4 HttpRequest (com.yahoo.container.jdisc.HttpRequest)3 QueryProfile (com.yahoo.search.query.profile.QueryProfile)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CompoundName (com.yahoo.processing.request.CompoundName)1 Properties (com.yahoo.search.query.Properties)1 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)1 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)1 File (java.io.File)1