Search in sources :

Example 31 with CompiledQueryProfile

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

the class QueryProfileTypeInheritanceTestCase method testStrictIsInherited.

public void testStrictIsInherited() {
    type.inherited().add(userStrict);
    type.freeze();
    userStrict.freeze();
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    test.set("myUserInteger", "37", (QueryProfileRegistry) null);
    try {
        test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
        fail("Should have failed");
    } catch (IllegalArgumentException e) {
        assertEquals("'myUnknownInteger' is not declared in query profile type 'testtype', and the type is strict", e.getCause().getMessage());
    }
    CompiledQueryProfile ctest = test.compile(null);
    assertEquals(37, ctest.get("myUserInteger"));
    assertNull(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)

Example 32 with CompiledQueryProfile

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

the class QueryProfileVariantsTestCase method testIncompatibleDimensions.

public void testIncompatibleDimensions() {
    QueryProfile alert = new QueryProfile("alert");
    QueryProfile backendBase = new QueryProfile("backendBase");
    backendBase.setDimensions(new String[] { "sort", "resulttypes", "rss" });
    backendBase.set("custid", "s", (QueryProfileRegistry) null);
    QueryProfile backend = new QueryProfile("backend");
    backend.setDimensions(new String[] { "sort", "offset", "resulttypes", "rss", "age", "lang", "fr", "entry" });
    backend.addInherited(backendBase);
    QueryProfile web = new QueryProfile("web");
    web.setDimensions(new String[] { "entry", "recency" });
    web.set("fr", "alerts", new String[] { "alert" }, null);
    alert.set("config.backend.vertical.news", backend, (QueryProfileRegistry) null);
    alert.set("config.backend.multimedia", web, (QueryProfileRegistry) null);
    backend.set("custid", "yahoo/alerts", new String[] { null, null, null, null, null, "en-US", null, "alert" }, null);
    CompiledQueryProfile cAlert = alert.compile(null);
    assertEquals("yahoo/alerts", cAlert.get("config.backend.vertical.news.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 33 with CompiledQueryProfile

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

the class QueryProfileVariantsTestCase method testVariantInheritanceWithCompoundReferences.

public void testVariantInheritanceWithCompoundReferences() {
    QueryProfile test = new QueryProfile("test");
    test.setDimensions(new String[] { "x" });
    test.set("a.b", "default-a.b", (QueryProfileRegistry) null);
    QueryProfile ac = new QueryProfile("ac");
    ac.set("a.c", "referenced-a.c", (QueryProfileRegistry) null);
    test.addInherited(ac, new String[] { "x1" });
    test.set("a.b", "x1-a.b", new String[] { "x1" }, null);
    CompiledQueryProfile ctest = test.compile(null);
    assertEquals("Basic functionality", "default-a.b", ctest.get("a.b"));
    assertEquals("Inherited variance reference works", "referenced-a.c", ctest.get("a.c", toMap("x=x1")));
    assertEquals("Inherited variance reference overriding works", "x1-a.b", ctest.get("a.b", 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 34 with CompiledQueryProfile

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

the class QueryProfileVariantsTestCase method testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel.

public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtFirstLevel() {
    QueryProfile test = new QueryProfile("test");
    test.setDimensions(new String[] { "x" });
    test.set("o.a.b", "default-a.b", (QueryProfileRegistry) null);
    QueryProfile ac = new QueryProfile("ac");
    ac.set("o.a.c", "referenced-a.c", (QueryProfileRegistry) null);
    test.addInherited(ac, new String[] { "x1" });
    test.set("o.a.b", "x1-a.b", new String[] { "x1" }, null);
    CompiledQueryProfile ctest = test.compile(null);
    assertEquals("Basic functionality", "default-a.b", ctest.get("o.a.b"));
    assertEquals("Inherited variance reference works", "referenced-a.c", ctest.get("o.a.c", toMap("x=x1")));
    assertEquals("Inherited variance reference overriding works", "x1-a.b", ctest.get("o.a.b", 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 35 with CompiledQueryProfile

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

the class QueryProfileVariantsTestCase method testVariantsAreResolvedBeforeInheritance.

public void testVariantsAreResolvedBeforeInheritance() {
    QueryProfile parent = new QueryProfile("parent");
    parent.setDimensions(new String[] { "x", "y" });
    parent.set("a", "p.a.default", (QueryProfileRegistry) null);
    parent.set("a", "p.a.x1.y1", new String[] { "x1", "y1" }, null);
    parent.set("a", "p.a.x1.y2", new String[] { "x1", "y2" }, null);
    parent.set("b", "p.b.default", (QueryProfileRegistry) null);
    parent.set("b", "p.b.x1.y1", new String[] { "x1", "y1" }, null);
    parent.set("b", "p.b.x1.y2", new String[] { "x1", "y2" }, null);
    QueryProfile child = new QueryProfile("child");
    child.setDimensions(new String[] { "x", "y" });
    child.addInherited(parent);
    child.set("a", "c.a.default", (QueryProfileRegistry) null);
    child.set("a", "c.a.x1.y1", new String[] { "x1", "y1" }, null);
    CompiledQueryProfile cchild = child.compile(null);
    assertEquals("c.a.default", cchild.get("a"));
    assertEquals("c.a.x1.y1", cchild.get("a", toMap("x=x1", "y=y1")));
    assertEquals("c.a.default", cchild.get("a", toMap("x=x1", "y=y2")));
    assertEquals("p.b.default", cchild.get("b"));
    assertEquals("p.b.x1.y1", cchild.get("b", toMap("x=x1", "y=y1")));
    assertEquals("p.b.x1.y2", cchild.get("b", toMap("x=x1", "y=y2")));
}
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)

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