Search in sources :

Example 16 with CompiledQueryProfile

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

the class QueryProfileVariantsTestCase method testIncompatibleDimensionsSimplified.

public void testIncompatibleDimensionsSimplified() {
    QueryProfile alert = new QueryProfile("alert");
    QueryProfile backendBase = new QueryProfile("backendBase");
    backendBase.set("custid", "s", (QueryProfileRegistry) null);
    QueryProfile backend = new QueryProfile("backend");
    backend.setDimensions(new String[] { "sort", "lang", "fr", "entry" });
    backend.set("custid", "yahoo/alerts", new String[] { null, "en-US", null, "alert" }, null);
    backend.addInherited(backendBase);
    QueryProfile web = new QueryProfile("web");
    web.setDimensions(new String[] { "entry", "recency" });
    web.set("fr", "alerts", new String[] { "alert" }, null);
    alert.set("vertical", backend, (QueryProfileRegistry) null);
    alert.set("multimedia", web, (QueryProfileRegistry) null);
    CompiledQueryProfile cAlert = alert.compile(null);
    assertEquals("yahoo/alerts", cAlert.get("vertical.custid", toMap("entry=alert", "intl=us", "lang=en-US")));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile)

Example 17 with CompiledQueryProfile

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

the class QueryProfileVariantsTestCase method testSimple.

public void testSimple() {
    QueryProfile profile = new QueryProfile("a");
    profile.set("a", "a.deflt", (QueryProfileRegistry) null);
    profile.setDimensions(new String[] { "x", "y", "z" });
    profile.set("a", "a.1.*.*", new String[] { "x1", null, null }, null);
    profile.set("a", "a.1.*.1", new String[] { "x1", null, "z1" }, null);
    profile.set("a", "a.1.*.5", new String[] { "x1", null, "z5" }, null);
    profile.set("a", "a.1.1.*", new String[] { "x1", "y1", null }, null);
    profile.set("a", "a.1.5.*", new String[] { "x1", "y5", null }, null);
    profile.set("a", "a.1.1.1", new String[] { "x1", "y1", "z1" }, null);
    profile.set("a", "a.2.1.1", new String[] { "x2", "y1", "z1" }, null);
    profile.set("a", "a.1.2.2", new String[] { "x1", "y2", "z2" }, null);
    profile.set("a", "a.1.2.3", new String[] { "x1", "y2", "z3" }, null);
    // Same as ,null,null
    profile.set("a", "a.2.*.*", new String[] { "x2" }, null);
    CompiledQueryProfile cprofile = profile.compile(null);
    // Perfect matches
    assertGet("a.deflt", "a", new String[] { null, null, null }, profile, cprofile);
    assertGet("a.1.*.*", "a", new String[] { "x1", null, null }, profile, cprofile);
    assertGet("a.1.1.*", "a", new String[] { "x1", "y1", null }, profile, cprofile);
    assertGet("a.1.5.*", "a", new String[] { "x1", "y5", null }, profile, cprofile);
    assertGet("a.1.*.1", "a", new String[] { "x1", null, "z1" }, profile, cprofile);
    assertGet("a.1.*.5", "a", new String[] { "x1", null, "z5" }, profile, cprofile);
    assertGet("a.1.1.1", "a", new String[] { "x1", "y1", "z1" }, profile, cprofile);
    assertGet("a.2.1.1", "a", new String[] { "x2", "y1", "z1" }, profile, cprofile);
    assertGet("a.1.2.2", "a", new String[] { "x1", "y2", "z2" }, profile, cprofile);
    assertGet("a.1.2.3", "a", new String[] { "x1", "y2", "z3" }, profile, cprofile);
    assertGet("a.2.*.*", "a", new String[] { "x2", null, null }, profile, cprofile);
    // Wildcard matches
    assertGet("a.deflt", "a", new String[] { "x?", "y?", "z?" }, profile, cprofile);
    assertGet("a.deflt", "a", new String[] { "x?", "y1", "z1" }, profile, cprofile);
    assertGet("a.1.*.*", "a", new String[] { "x1", "y?", "z?" }, profile, cprofile);
    assertGet("a.1.*.*", "a", new String[] { "x1", "y?", "z?" }, profile, cprofile);
    assertGet("a.1.1.*", "a", new String[] { "x1", "y1", "z?" }, profile, cprofile);
    assertGet("a.1.*.1", "a", new String[] { "x1", "y?", "z1" }, profile, cprofile);
    assertGet("a.1.5.*", "a", new String[] { "x1", "y5", "z?" }, profile, cprofile);
    assertGet("a.1.*.5", "a", new String[] { "x1", "y?", "z5" }, profile, cprofile);
    // Left dimension gets precedence
    assertGet("a.1.5.*", "a", new String[] { "x1", "y5", "z5" }, profile, cprofile);
    assertGet("a.2.*.*", "a", new String[] { "x2", "y?", "z?" }, profile, cprofile);
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile)

Example 18 with CompiledQueryProfile

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

the class QueryProfileVariantsTestCase method testVariantInheritanceOverridesBaseInheritanceMixed.

public void testVariantInheritanceOverridesBaseInheritanceMixed() {
    QueryProfile root = new QueryProfile("root");
    root.set("model.defaultIndex", "default", (QueryProfileRegistry) null);
    QueryProfile multi = new QueryProfile("multi");
    multi.setDimensions(new String[] { "x" });
    multi.set("model.defaultIndex", "title", (QueryProfileRegistry) null);
    multi.set("model.queryString", "modelQuery", (QueryProfileRegistry) null);
    multi.addInherited(root, new String[] { "x1" });
    multi.set("model.queryString", "modelVariantQuery", new String[] { "x1" }, null);
    CompiledQueryProfile cmulti = multi.compile(null);
    assertEquals("default", cmulti.get("model.defaultIndex", toMap("x=x1")));
    assertEquals("modelVariantQuery", cmulti.get("model.queryString", toMap("x=x1")));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile)

Example 19 with CompiledQueryProfile

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

the class QueryProfileVariantsCloneTestCase method test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning.

/**
 * Test for Ticket 4882480.
 */
@Test
public void test_that_interior_and_leaf_values_on_a_path_are_preserved_when_cloning() {
    Map<String, String> dimensionBinding = createDimensionBinding("location", "norway");
    QueryProfile profile = new QueryProfile("profile");
    profile.setDimensions(keys(dimensionBinding));
    DimensionValues dimensionValues = DimensionValues.createFrom(values(dimensionBinding));
    profile.set("interior.leaf", "leafValue", dimensionValues, null);
    profile.set("interior", "interiorValue", dimensionValues, null);
    CompiledQueryProfile clone = profile.compile(null).clone();
    assertEquals(profile.get("interior", dimensionBinding, null), clone.get("interior", dimensionBinding));
    assertEquals(profile.get("interior.leaf", dimensionBinding, null), clone.get("interior.leaf", dimensionBinding));
}
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) DimensionValues(com.yahoo.search.query.profile.DimensionValues) Test(org.junit.Test)

Example 20 with CompiledQueryProfile

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

the class QueryProfileTypeTestCase method testTypedAssignmentOfQueryProfilesNonStrict.

/**
 * Tests assigning a subprofile directly
 */
public void testTypedAssignmentOfQueryProfilesNonStrict() {
    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);
    assertWrongType(profile, "reference to a query profile", "myQueryProfile", "aString");
    profile.set("myQueryProfile", map1, registry);
    // Legal because this is not strict
    profile.set("someMap", map2, registry);
    assertWrongType(profile, "reference to a query profile of type 'user'", "myUserQueryProfile", map1);
    profile.set("myUserQueryProfile", myUser, registry);
    CompiledQueryProfile cprofile = profile.compile(null);
    assertEquals("value1", cprofile.get("myQueryProfile.key1"));
    assertEquals("value2", 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) 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