Search in sources :

Example 56 with QueryProfile

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

the class PatchMatchingTestCase method testPatchMatchingVersions.

/**
 * Check that the path matching works with versioned profiles
 */
public void testPatchMatchingVersions() {
    QueryProfileType type = new QueryProfileType("type");
    type.setMatchAsPath(true);
    QueryProfile a = new QueryProfile("a");
    a.setType(type);
    QueryProfile abee11 = new QueryProfile("a/bee:1.1");
    abee11.setType(type);
    abee11.addInherited(a);
    QueryProfile abee13 = new QueryProfile("a/bee:1.3");
    abee13.setType(type);
    abee13.addInherited(a);
    QueryProfile abeece = new QueryProfile("a/bee/ce");
    abeece.setType(type);
    abeece.addInherited(abee13);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(a);
    registry.register(abee11);
    registry.register(abee13);
    registry.register(abeece);
    registry.freeze();
    // No "default" registered
    assertNull(registry.findQueryProfile(null));
    assertEquals("a", registry.findQueryProfile("a").getId().getName());
    assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee:1.1").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee:1").getId().toString());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
    assertEquals("a/bee:1.1", registry.findQueryProfile("a/bee/cede:1.1").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede").getId().toString());
    assertEquals("a/bee:1.3", registry.findQueryProfile("a/bee/cede:1").getId().toString());
    assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
    assertNull(registry.findQueryProfile("abee"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 57 with QueryProfile

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

the class PatchMatchingTestCase method testQuirkyNames.

public void testQuirkyNames() {
    QueryProfileType type = new QueryProfileType("type");
    type.setMatchAsPath(true);
    QueryProfile a = new QueryProfile("/a");
    a.setType(type);
    QueryProfile abee = new QueryProfile("/a//bee");
    abee.setType(type);
    abee.addInherited(a);
    QueryProfile abeece = new QueryProfile("/a//bee/ce/");
    abeece.setType(type);
    abeece.addInherited(abee);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(a);
    registry.register(abee);
    registry.register(abeece);
    registry.freeze();
    // No "default" registered
    assertNull(registry.findQueryProfile(null));
    assertEquals("/a", registry.findQueryProfile("/a").getId().getName());
    assertNull(registry.findQueryProfile("a"));
    assertEquals("/a//bee", registry.findQueryProfile("/a//bee").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee").getId().getName());
    assertEquals("/a//bee/ce/", registry.findQueryProfile("/a//bee/ce/dee/eee/").getId().getName());
    assertEquals("/a//bee", registry.findQueryProfile("/a//bee/cede").getId().getName());
    assertEquals("/a", registry.findQueryProfile("/a/foo/bee/cede").getId().getName());
    assertEquals("/a", registry.findQueryProfile("/a/bee").getId().getName());
    assertNull(registry.findQueryProfile("abee"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 58 with QueryProfile

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

the class PatchMatchingTestCase method testPatchMatching.

public void testPatchMatching() {
    QueryProfileType type = new QueryProfileType("type");
    type.setMatchAsPath(true);
    QueryProfile a = new QueryProfile("a");
    a.setType(type);
    QueryProfile abee = new QueryProfile("a/bee");
    abee.setType(type);
    abee.addInherited(a);
    QueryProfile abeece = new QueryProfile("a/bee/ce");
    abeece.setType(type);
    abeece.addInherited(abee);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(a);
    registry.register(abee);
    registry.register(abeece);
    registry.freeze();
    // No "default" registered
    assertNull(registry.findQueryProfile(null));
    assertEquals("a", registry.findQueryProfile("a").getId().getName());
    assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce/dee/eee/").getId().getName());
    assertEquals("a/bee", registry.findQueryProfile("a/bee/cede").getId().getName());
    assertEquals("a", registry.findQueryProfile("a/foo/bee/cede").getId().getName());
    assertNull(registry.findQueryProfile("abee"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 59 with QueryProfile

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

the class PatchMatchingTestCase method testNoPatchMatching.

public void testNoPatchMatching() {
    QueryProfileType type = new QueryProfileType("type");
    // Default, but set here for clarity
    type.setMatchAsPath(false);
    QueryProfile a = new QueryProfile("a");
    a.setType(type);
    QueryProfile abee = new QueryProfile("a/bee");
    abee.setType(type);
    abee.addInherited(a);
    QueryProfile abeece = new QueryProfile("a/bee/ce");
    abeece.setType(type);
    abeece.addInherited(abee);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(a);
    registry.register(abee);
    registry.register(abeece);
    registry.freeze();
    // No "default" registered
    assertNull(registry.findQueryProfile(null));
    assertEquals("a", registry.findQueryProfile("a").getId().getName());
    assertEquals("a/bee", registry.findQueryProfile("a/bee").getId().getName());
    assertEquals("a/bee/ce", registry.findQueryProfile("a/bee/ce").getId().getName());
    // Different from test above
    assertNull(registry.findQueryProfile("a/bee/ce/dee"));
    // Different from test above
    assertNull(registry.findQueryProfile("a/bee/ce/dee/eee/"));
    // Different from test above
    assertNull(registry.findQueryProfile("a/bee/cede"));
    // Different from test above
    assertNull(registry.findQueryProfile("a/foo/bee/cede"));
    assertNull(registry.findQueryProfile("abee"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileType(com.yahoo.search.query.profile.types.QueryProfileType)

Example 60 with QueryProfile

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

the class QueryProfileTypeTestCase method testTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile.

/**
 * 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.
 * The whole thing is accessed through a two levels of nontyped top-level profiles
 */
public void testTypedOverridingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
    QueryProfile topMap = new QueryProfile("topMap");
    QueryProfile subMap = new QueryProfile("topSubMap");
    topMap.set("subMap", subMap, registry);
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    subMap.set("typeProfile", test, registry);
    QueryProfile myUser = new QueryProfile("myUser");
    myUser.setType(user);
    myUser.set("myUserString", "userValue1", registry);
    myUser.set("myUserInteger", 442, registry);
    test.set("myUserQueryProfile", myUser, registry);
    QueryProfile newUser = new QueryProfile("newUser");
    newUser.setType(user);
    newUser.set("myUserString", "newUserValue1", registry);
    newUser.set("myUserInteger", 845, registry);
    registry.register(topMap);
    registry.register(subMap);
    registry.register(test);
    registry.register(myUser);
    registry.register(newUser);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myUserQueryProfile=newUser", com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("topMap"));
    assertEquals(0, query.errors().size());
    assertEquals("newUserValue1", query.properties().get("subMap.typeProfile.myUserQueryProfile.myUserString"));
    assertEquals(845, query.properties().get("subMap.typeProfile.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) Query(com.yahoo.search.Query)

Aggregations

QueryProfile (com.yahoo.search.query.profile.QueryProfile)161 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)92 Query (com.yahoo.search.Query)63 BackedOverridableQueryProfile (com.yahoo.search.query.profile.BackedOverridableQueryProfile)35 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)28 Test (org.junit.Test)26 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)24 QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)21 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)12 Properties (com.yahoo.search.query.Properties)8 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)5 SubstituteString (com.yahoo.search.query.profile.SubstituteString)4 QueryProfilesConfig (com.yahoo.search.query.profile.config.QueryProfilesConfig)4 Element (org.w3c.dom.Element)4 QueryException (com.yahoo.prelude.query.QueryException)3 Properties (com.yahoo.processing.request.Properties)3 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)3 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)3 ComponentSpecification (com.yahoo.component.ComponentSpecification)2