Search in sources :

Example 21 with CompiledQueryProfile

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

the class QueryProfileTypeTestCase method testTypedOverridingOfQueryProfileReferencesNonStrictThroughQuery.

/**
 * Tests overriding a subprofile as an id string through the query.
 * Here there exists a user profile already, and then a new one is overwritten
 */
public void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQuery() {
    QueryProfile profile = new QueryProfile("test");
    profile.setType(type);
    QueryProfile myUser = new QueryProfile("myUser");
    myUser.setType(user);
    myUser.set("myUserString", "userValue1", registry);
    myUser.set("myUserInteger", 442, registry);
    QueryProfile newUser = new QueryProfile("newUser");
    newUser.setType(user);
    newUser.set("myUserString", "newUserValue1", registry);
    newUser.set("myUserInteger", 845, registry);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(profile);
    registry.register(myUser);
    registry.register(newUser);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    CompiledQueryProfile cprofile = cRegistry.getComponent("test");
    Query query = new Query(HttpRequest.createTestRequest("?myUserQueryProfile=newUser", com.yahoo.jdisc.http.HttpRequest.Method.GET), cprofile);
    assertEquals(0, query.errors().size());
    assertEquals("newUserValue1", query.properties().get("myUserQueryProfile.myUserString"));
    assertEquals(845, query.properties().get("myUserQueryProfile.myUserInteger"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) Query(com.yahoo.search.Query) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)

Example 22 with CompiledQueryProfile

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

the class QueryProfileTypeTestCase method testTypedAssignmentOfQueryProfileReferencesNonStrictThroughQuery.

/**
 * Tests overriding a subprofile as an id string through the query.
 * Here no user profile is set before it is assigned in the query
 */
public void testTypedAssignmentOfQueryProfileReferencesNonStrictThroughQuery() {
    QueryProfile profile = new QueryProfile("test");
    profile.setType(type);
    QueryProfile newUser = new QueryProfile("newUser");
    newUser.setType(user);
    newUser.set("myUserString", "newUserValue1", registry);
    newUser.set("myUserInteger", 845, registry);
    registry.register(profile);
    registry.register(newUser);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    CompiledQueryProfile cprofile = cRegistry.getComponent("test");
    Query query = new Query(HttpRequest.createTestRequest("?myUserQueryProfile=newUser", com.yahoo.jdisc.http.HttpRequest.Method.GET), cprofile);
    assertEquals(0, query.errors().size());
    assertEquals("newUserValue1", query.properties().get("myUserQueryProfile.myUserString"));
    assertEquals(845, query.properties().get("myUserQueryProfile.myUserInteger"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) Query(com.yahoo.search.Query)

Example 23 with CompiledQueryProfile

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

the class QueryProfileTypeTestCase method testTypedAssignmentOfQueryProfileReferencesNonStrict.

/**
 * Tests assigning a subprofile as an id string
 */
public void testTypedAssignmentOfQueryProfileReferencesNonStrict() {
    QueryProfile profile = new QueryProfile("test");
    profile.setType(type);
    QueryProfile map1 = new QueryProfile("myMap1");
    map1.set("key1", "value1", registry);
    QueryProfile map2 = new QueryProfile("myMap2");
    map2.set("key2", "value2", registry);
    QueryProfile myUser = new QueryProfile("myUser");
    myUser.setType(user);
    myUser.set("myUserString", "userValue1", registry);
    myUser.set("myUserInteger", 442, registry);
    registry.register(profile);
    registry.register(map1);
    registry.register(map2);
    registry.register(myUser);
    assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
    registry.register(map1);
    profile.set("myQueryProfile", "myMap1", registry);
    registry.register(map2);
    // NOTICE: Will set as a string because we cannot know this is a reference
    profile.set("someMap", "myMap2", registry);
    assertWrongType(profile, "reference to a query profile of type 'user'", "myUserQueryProfile", "myMap1");
    registry.register(myUser);
    profile.set("myUserQueryProfile", "myUser", registry);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    CompiledQueryProfile cprofile = cRegistry.getComponent("test");
    assertEquals("value1", cprofile.get("myQueryProfile.key1"));
    assertEquals("myMap2", cprofile.get("someMap"));
    assertNull("Asking for an value which cannot be completely resolved returns null", cprofile.get("someMap.key2"));
    assertEquals("userValue1", cprofile.get("myUserQueryProfile.myUserString"));
    assertEquals(442, cprofile.get("myUserQueryProfile.myUserInteger"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile)

Example 24 with CompiledQueryProfile

use of com.yahoo.search.query.profile.compiled.CompiledQueryProfile 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 25 with CompiledQueryProfile

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

the class QueryProfileTypeInheritanceTestCase method testInheritance.

public void testInheritance() {
    type.inherited().add(user);
    type.freeze();
    user.freeze();
    assertFalse(type.isOverridable("myUserString"));
    assertEquals("myUserInteger", type.getField("myUserInteger").getName());
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    test.set("myUserInteger", "37", (QueryProfileRegistry) null);
    test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
    CompiledQueryProfile ctest = test.compile(null);
    assertEquals(37, ctest.get("myUserInteger"));
    assertEquals("38", ctest.get("myUnknownInteger"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile)

Aggregations

CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)48 QueryProfile (com.yahoo.search.query.profile.QueryProfile)37 BackedOverridableQueryProfile (com.yahoo.search.query.profile.BackedOverridableQueryProfile)18 Query (com.yahoo.search.Query)8 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)8 Test (org.junit.Test)7 CompoundName (com.yahoo.processing.request.CompoundName)5 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)4 HashMap (java.util.HashMap)4 HttpRequest (com.yahoo.container.jdisc.HttpRequest)3 QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)3 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)3 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)3 Map (java.util.Map)3 QueryProfileConfigurer (com.yahoo.search.query.profile.config.QueryProfileConfigurer)2 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)2 HashSet (java.util.HashSet)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Chain (com.yahoo.component.chain.Chain)1 Renderer (com.yahoo.processing.rendering.Renderer)1