Search in sources :

Example 26 with QueryProfileRegistry

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

the class QueryProfileConfigurer method configure.

public void configure(QueryProfilesConfig config) {
    QueryProfileRegistry registry = createFromConfig(config);
    setCurrentRegistry(registry);
}
Also used : QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 27 with QueryProfileRegistry

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

the class QueryProfileConfigurer method createFromConfig.

public static QueryProfileRegistry createFromConfig(QueryProfilesConfig config) {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    // Pass 1: Create all profiles and profile types
    for (QueryProfilesConfig.Queryprofiletype profileTypeConfig : config.queryprofiletype()) {
        createProfileType(profileTypeConfig, registry.getTypeRegistry());
    }
    for (QueryProfilesConfig.Queryprofile profileConfig : config.queryprofile()) {
        createProfile(profileConfig, registry);
    }
    // Pass 2: Resolve references and add content
    for (QueryProfilesConfig.Queryprofiletype profileTypeConfig : config.queryprofiletype()) {
        fillProfileType(profileTypeConfig, registry.getTypeRegistry());
    }
    // To ensure topological sorting, using DPS. This will _NOT_ detect cycles (but it will not fail if they
    // exist either)
    Set<ComponentId> filled = new HashSet<>();
    for (QueryProfilesConfig.Queryprofile profileConfig : config.queryprofile()) {
        fillProfile(profileConfig, config, registry, filled);
    }
    registry.freeze();
    return registry;
}
Also used : QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) ComponentId(com.yahoo.component.ComponentId) HashSet(java.util.HashSet)

Example 28 with QueryProfileRegistry

use of com.yahoo.search.query.profile.QueryProfileRegistry 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 29 with QueryProfileRegistry

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

the class QueryFromProfileTestCase method testQueryFromProfile3.

public void testQueryFromProfile3() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfileType rootType = new QueryProfileType("root");
    rootType.inherited().add(registry.getTypeRegistry().getComponent("native"));
    registry.getTypeRegistry().register(rootType);
    QueryProfile root = new QueryProfile("root");
    root.setType(rootType);
    registry.register(root);
    QueryProfile queryBest = new QueryProfile("querybest");
    queryBest.setType(registry.getTypeRegistry().getComponent("model"));
    queryBest.set("queryString", "best", registry);
    registry.register(queryBest);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    Query query = new Query(HttpRequest.createTestRequest("?query=overrides&model=querybest", Method.GET), cRegistry.getComponent("root"));
    assertEquals("overrides", query.properties().get("model.queryString"));
    assertEquals("overrides", query.getModel().getQueryTree().toString());
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 30 with QueryProfileRegistry

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

the class QueryFromProfileTestCase method testQueryFromProfile2.

public void testQueryFromProfile2() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfileType rootType = new QueryProfileType("root");
    rootType.inherited().add(registry.getTypeRegistry().getComponent("native"));
    registry.getTypeRegistry().register(rootType);
    QueryProfile root = new QueryProfile("root");
    root.setType(rootType);
    registry.register(root);
    QueryProfile queryBest = new QueryProfile("querybest");
    queryBest.setType(registry.getTypeRegistry().getComponent("model"));
    queryBest.set("queryString", "best", registry);
    registry.register(queryBest);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    Query query = new Query(HttpRequest.createTestRequest("?query=overrides&model=querybest", Method.GET), cRegistry.getComponent("root"));
    assertEquals("overrides", query.properties().get("model.queryString"));
    assertEquals("overrides", query.getModel().getQueryTree().toString());
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Aggregations

QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)68 Test (org.junit.Test)38 QueryProfile (com.yahoo.search.query.profile.QueryProfile)24 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)16 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)16 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)14 Query (com.yahoo.search.Query)11 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)11 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)11 Pair (com.yahoo.collections.Pair)8 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)8 Search (com.yahoo.searchdefinition.Search)8 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)6 SDField (com.yahoo.searchdefinition.document.SDField)5 ComponentId (com.yahoo.component.ComponentId)4 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4