Search in sources :

Example 36 with QueryProfileRegistry

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

the class ParametersTestCase method createProfile.

public CompiledQueryProfile createProfile() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfile profile = new QueryProfile("test");
    profile.set("model.filter", "+year:2001", registry);
    profile.set("model.language", "en", registry);
    return registry.compile().findQueryProfile("test");
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 37 with QueryProfileRegistry

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

the class OverrideTestCase method testUntypedNestedUnoverridable.

/**
 * Check that non-overridables are protected also in nested untyped references
 */
public void testUntypedNestedUnoverridable() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfile topMap = new QueryProfile("topMap");
    registry.register(topMap);
    QueryProfile subMap = new QueryProfile("topSubMap");
    topMap.set("subMap", subMap, registry);
    registry.register(subMap);
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    subMap.set("test", test, registry);
    registry.register(test);
    QueryProfile myUser = new QueryProfile("user");
    myUser.setType(user);
    myUser.set("myUserString", "finalValue", registry);
    test.set("myUserQueryProfile", myUser, registry);
    registry.register(myUser);
    registry.freeze();
    Query query = new Query(HttpRequest.createTestRequest("?subMap.test.myUserQueryProfile.myUserString=newValue", Method.GET), registry.compile().getComponent("topMap"));
    assertEquals(0, query.errors().size());
    assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
    query.properties().set("subMap.test.myUserQueryProfile.myUserString", "newValue");
    assertEquals("finalValue", query.properties().get("subMap.test.myUserQueryProfile.myUserString"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 38 with QueryProfileRegistry

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

the class OverrideTestCase method testInheritedNonOverridableInType.

/**
 * Tests overridability in an inherited field
 */
public void testInheritedNonOverridableInType() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    test.set("myString", "finalString", (QueryProfileRegistry) null);
    registry.register(test);
    QueryProfile profile = new QueryProfile("profile");
    profile.addInherited(test);
    registry.register(profile);
    registry.freeze();
    Query query = new Query(HttpRequest.createTestRequest("?myString=newString", Method.GET), registry.compile().getComponent("test"));
    assertEquals(0, query.errors().size());
    assertEquals("finalString", query.properties().get("myString"));
    query.properties().set("myString", "newString");
    assertEquals("finalString", query.properties().get("myString"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 39 with QueryProfileRegistry

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

the class OverrideTestCase method testUnoverridableQueryProfile.

/**
 * Check that a query profile cannot be overridden
 */
public void testUnoverridableQueryProfile() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    registry.register(test);
    QueryProfile myUser = new QueryProfile("user");
    myUser.setType(user);
    myUser.set("myUserInteger", 1, registry);
    myUser.set("myUserString", "userValue", registry);
    test.set("myUserQueryProfile", myUser, registry);
    registry.register(myUser);
    QueryProfile otherUser = new QueryProfile("otherUser");
    otherUser.setType(user);
    otherUser.set("myUserInteger", 2, registry);
    registry.register(otherUser);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    Query query = new Query(HttpRequest.createTestRequest("?myUserQueryprofile=otherUser", Method.GET), cRegistry.getComponent("test"));
    assertEquals(0, query.errors().size());
    assertEquals(1, query.properties().get("myUserQueryProfile.myUserInteger"));
}
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)

Example 40 with QueryProfileRegistry

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

the class OverrideTestCase method testInheritedNonOverridableInProfile.

/**
 * Tests overridability in an inherited field
 */
public void testInheritedNonOverridableInProfile() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    test.set("myInteger", 1, registry);
    test.setOverridable("myInteger", false, null);
    registry.register(test);
    QueryProfile profile = new QueryProfile("profile");
    profile.addInherited(test);
    registry.register(profile);
    registry.freeze();
    Query query = new Query(HttpRequest.createTestRequest("?myInteger=32", Method.GET), registry.compile().getComponent("test"));
    assertEquals(0, query.errors().size());
    assertEquals(1, query.properties().get("myInteger"));
    query.properties().set("myInteger", 32);
    assertEquals(1, query.properties().get("myInteger"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

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