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);
}
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;
}
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());
}
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());
}
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());
}
Aggregations