Search in sources :

Example 1 with QueryProfileTypeRegistry

use of com.yahoo.search.query.profile.types.QueryProfileTypeRegistry in project vespa by vespa-engine.

the class RankProfileTestCase method setupQueryProfileTypes.

private static QueryProfileRegistry setupQueryProfileTypes() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfileTypeRegistry typeRegistry = registry.getTypeRegistry();
    QueryProfileType type = new QueryProfileType(new ComponentId("testtype"));
    type.addField(new FieldDescription("ranking.features.query(tensor1)", FieldType.fromString("tensor(x[10])", typeRegistry)), typeRegistry);
    type.addField(new FieldDescription("ranking.features.query(tensor2)", FieldType.fromString("tensor(y{})", typeRegistry)), typeRegistry);
    type.addField(new FieldDescription("ranking.features.invalid(tensor3)", FieldType.fromString("tensor(x{})", typeRegistry)), typeRegistry);
    type.addField(new FieldDescription("ranking.features.query(numeric)", FieldType.fromString("integer", typeRegistry)), typeRegistry);
    typeRegistry.register(type);
    return registry;
}
Also used : QueryProfileTypeRegistry(com.yahoo.search.query.profile.types.QueryProfileTypeRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) ComponentId(com.yahoo.component.ComponentId) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription)

Example 2 with QueryProfileTypeRegistry

use of com.yahoo.search.query.profile.types.QueryProfileTypeRegistry in project vespa by vespa-engine.

the class QueryProfilesTestCase method testQueryProfiles.

@Test
public void testQueryProfiles() throws IOException {
    final boolean mandatory = true;
    final boolean overridable = true;
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfileTypeRegistry typeRegistry = registry.getTypeRegistry();
    QueryProfileType userType = new QueryProfileType("user");
    userType.setStrict(true);
    userType.addField(new FieldDescription("robot", FieldType.fromString("boolean", typeRegistry), "machine automaton", mandatory, !overridable));
    userType.addField(new FieldDescription("ads", FieldType.fromString("string", typeRegistry), mandatory, overridable));
    userType.addField(new FieldDescription("age", FieldType.fromString("integer", typeRegistry), !mandatory, overridable));
    typeRegistry.register(userType);
    QueryProfileType rootType = new QueryProfileType("root");
    QueryProfileType nativeProfile = typeRegistry.getComponent("native");
    assertNotNull(nativeProfile);
    assertTrue(nativeProfile.isBuiltin());
    rootType.inherited().add(nativeProfile);
    rootType.setMatchAsPath(true);
    rootType.addField(new FieldDescription("user", FieldType.fromString("query-profile:user", typeRegistry), mandatory, overridable));
    typeRegistry.register(rootType);
    QueryProfileType marketType = new QueryProfileType("market");
    marketType.inherited().add(rootType);
    marketType.addField(new FieldDescription("market", FieldType.fromString("string", typeRegistry), !mandatory, !overridable));
    typeRegistry.register(marketType);
    QueryProfile defaultProfile = new QueryProfile("default");
    defaultProfile.set("ranking", "production23", registry);
    defaultProfile.set("representation.defaultIndex", "title", registry);
    defaultProfile.setOverridable("representation.defaultIndex", false, null);
    registry.register(defaultProfile);
    QueryProfile test = new QueryProfile("test");
    test.set("tracelevel", 2, registry);
    registry.register(test);
    QueryProfile genericUser = new QueryProfile("genericUser");
    genericUser.setType(userType);
    genericUser.set("robot", false, registry);
    genericUser.set("ads", "all", registry);
    registry.register(genericUser);
    QueryProfile root = new QueryProfile("root");
    root.setType(rootType);
    root.addInherited(defaultProfile);
    root.addInherited(test);
    root.set("hits", 30, registry);
    root.setOverridable("hits", false, null);
    root.set("unique", "category", registry);
    root.set("user", genericUser, registry);
    root.set("defaultage", "7d", registry);
    registry.register(root);
    QueryProfile marketUser = new QueryProfile("marketUser");
    marketUser.setType(userType);
    marketUser.addInherited(genericUser);
    marketUser.set("ads", "none", registry);
    marketUser.set("age", 25, registry);
    registry.register(marketUser);
    QueryProfile market = new QueryProfile("root/market");
    market.setType(marketType);
    market.addInherited(root);
    market.set("hits", 15, registry);
    market.set("user", marketUser, registry);
    market.set("market", "some market", registry);
    market.set("marketHeading", "Market of %{market}", registry);
    registry.register(market);
    QueryProfile untypedUser = new QueryProfile("untypedUser");
    untypedUser.set("robot", false, registry);
    untypedUser.set("robot.type", "continent-class", registry);
    registry.register(untypedUser);
    assertConfig("query-profiles.cfg", registry);
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileTypeRegistry(com.yahoo.search.query.profile.types.QueryProfileTypeRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription) Test(org.junit.Test)

Example 3 with QueryProfileTypeRegistry

use of com.yahoo.search.query.profile.types.QueryProfileTypeRegistry in project vespa by vespa-engine.

the class TensorTransformTestCase method setupQueryProfileTypes.

private static QueryProfileRegistry setupQueryProfileTypes() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfileTypeRegistry typeRegistry = registry.getTypeRegistry();
    QueryProfileType type = new QueryProfileType(new ComponentId("testtype"));
    type.addField(new FieldDescription("ranking.features.query(q)", FieldType.fromString("tensor(x{})", typeRegistry)), typeRegistry);
    type.addField(new FieldDescription("ranking.features.query(n)", FieldType.fromString("integer", typeRegistry)), typeRegistry);
    typeRegistry.register(type);
    return registry;
}
Also used : QueryProfileTypeRegistry(com.yahoo.search.query.profile.types.QueryProfileTypeRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) ComponentId(com.yahoo.component.ComponentId) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription)

Example 4 with QueryProfileTypeRegistry

use of com.yahoo.search.query.profile.types.QueryProfileTypeRegistry in project vespa by vespa-engine.

the class FieldTypeTestCase method testConvertToFromString.

public void testConvertToFromString() {
    QueryProfileTypeRegistry registry = new QueryProfileTypeRegistry();
    registry.register(new QueryProfileType("foo"));
    assertEquals("string", FieldType.fromString("string", registry).stringValue());
    assertEquals("boolean", FieldType.fromString("boolean", registry).stringValue());
    assertEquals("query-profile", FieldType.fromString("query-profile", registry).stringValue());
    assertEquals("query-profile:foo", FieldType.fromString("query-profile:foo", registry).stringValue());
}
Also used : QueryProfileTypeRegistry(com.yahoo.search.query.profile.types.QueryProfileTypeRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 5 with QueryProfileTypeRegistry

use of com.yahoo.search.query.profile.types.QueryProfileTypeRegistry in project vespa by vespa-engine.

the class TypedProfilesConfigurationTestCase method testIt.

/**
 * Asserts that everything is read correctly from this configuration
 */
public void testIt() {
    QueryProfileConfigurer configurer = new QueryProfileConfigurer("file:src/test/java/com/yahoo/search/query/profile/config/test/typed-profiles.cfg");
    QueryProfileRegistry registry = configurer.getCurrentRegistry();
    QueryProfileTypeRegistry types = registry.getTypeRegistry();
    // Assert that each type was read correctly
    QueryProfileType testType = types.getComponent("testtype");
    assertEquals("testtype", testType.getId().getName());
    assertFalse(testType.isStrict());
    assertFalse(testType.getMatchAsPath());
    assertEquals(7, testType.fields().size());
    assertEquals("myString", testType.getField("myString").getName());
    assertTrue(testType.getField("myString").isMandatory());
    assertTrue(testType.getField("myString").isOverridable());
    assertFalse(testType.getField("myInteger").isMandatory());
    assertFalse(testType.getField("myInteger").isOverridable());
    FieldDescription field = testType.getField("myUserQueryProfile");
    assertEquals("reference to a query profile of type 'user'", field.getType().toInstanceDescription());
    assertTrue(field.getAliases().contains("myqp"));
    assertTrue(field.getAliases().contains("user-profile"));
    QueryProfileType testTypeStrict = types.getComponent("testtypestrict");
    assertTrue(testTypeStrict.isStrict());
    assertTrue(testTypeStrict.getMatchAsPath());
    assertEquals(7, testTypeStrict.fields().size());
    assertEquals("reference to a query profile of type 'userstrict'", testTypeStrict.getField("myUserQueryProfile").getType().toInstanceDescription());
    QueryProfileType user = types.getComponent("user");
    assertFalse(user.isStrict());
    assertFalse(user.getMatchAsPath());
    assertEquals(2, user.fields().size());
    assertEquals(String.class, user.getField("myUserString").getType().getValueClass());
    QueryProfileType userStrict = types.getComponent("userstrict");
    assertTrue(userStrict.isStrict());
    assertFalse(userStrict.getMatchAsPath());
    assertEquals(2, userStrict.fields().size());
}
Also used : QueryProfileConfigurer(com.yahoo.search.query.profile.config.QueryProfileConfigurer) QueryProfileTypeRegistry(com.yahoo.search.query.profile.types.QueryProfileTypeRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType) FieldDescription(com.yahoo.search.query.profile.types.FieldDescription)

Aggregations

QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)7 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)7 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)5 ComponentId (com.yahoo.component.ComponentId)4 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)4 QueryProfile (com.yahoo.search.query.profile.QueryProfile)1 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)1 QueryProfileConfigurer (com.yahoo.search.query.profile.config.QueryProfileConfigurer)1 Test (org.junit.Test)1