Search in sources :

Example 36 with QueryProfile

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

the class QueryProfileVariantsTestCase method testVariantNotInBaseSpaceVariantValue.

public void testVariantNotInBaseSpaceVariantValue() {
    QueryProfile test = new QueryProfile("test");
    test.setDimensions(new String[] { "x" });
    test.set("InX1Only", "x1", new String[] { "x 1" }, null);
    CompiledQueryProfile ctest = test.compile(null);
    assertEquals("x1", ctest.get("InX1Only", toMap("x=x 1")));
    assertEquals(null, ctest.get("InX1Only", toMap("x=x 2")));
    assertEquals(null, ctest.get("InX1Only"));
}
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 37 with QueryProfile

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

the class QueryProfileVariantsTestCase method testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel.

public void testVariantInheritanceWithTwoLevelCompoundReferencesVariantAtSecondLevel() {
    QueryProfile test = new QueryProfile("test");
    test.setDimensions(new String[] { "x" });
    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);
    QueryProfile top = new QueryProfile("top");
    top.set("o.a.b", "default-a.b", (QueryProfileRegistry) null);
    top.set("o", test, (QueryProfileRegistry) null);
    CompiledQueryProfile ctop = top.compile(null);
    assertEquals("Basic functionality", "default-a.b", ctop.get("o.a.b"));
    assertEquals("Inherited variance reference works", "referenced-a.c", ctop.get("o.a.c", toMap("x=x1")));
    // Note: Changed from x1-a.b in 4.2.3
    assertEquals("Inherited variance reference does not override value set in referent", "default-a.b", ctop.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 38 with QueryProfile

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

the class QueryProfileVariantsTestCase method testDimensionsInSuperType.

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

Example 39 with QueryProfile

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

the class QueryProfileVariantsTestCase method testVariantInheritanceOverridesBaseInheritanceComplex.

public void testVariantInheritanceOverridesBaseInheritanceComplex() {
    QueryProfile defaultQP = new QueryProfile("default");
    defaultQP.set("model.defaultIndex", "title", (QueryProfileRegistry) null);
    QueryProfile root = new QueryProfile("root");
    root.addInherited(defaultQP);
    root.set("model.defaultIndex", "default", (QueryProfileRegistry) null);
    QueryProfile querybest = new QueryProfile("querybest");
    querybest.set("defaultIndex", "title", (QueryProfileRegistry) null);
    querybest.set("queryString", "best", (QueryProfileRegistry) null);
    QueryProfile multi = new QueryProfile("multi");
    multi.setDimensions(new String[] { "x" });
    multi.addInherited(defaultQP);
    multi.set("model", querybest, (QueryProfileRegistry) null);
    multi.addInherited(root, new String[] { "x1" });
    multi.set("model.queryString", "love", new String[] { "x1" }, null);
    // Rumtimize
    defaultQP.freeze();
    root.freeze();
    querybest.freeze();
    multi.freeze();
    Properties runtime = new QueryProfileProperties(multi.compile(null));
    assertEquals("default", runtime.get("model.defaultIndex", toMap("x=x1")));
    assertEquals("love", runtime.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) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Properties(com.yahoo.search.query.Properties) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 40 with QueryProfile

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

the class QueryProfileVariantsTestCase method testQueryProfileReferences.

public void testQueryProfileReferences() {
    QueryProfile main = new QueryProfile("main");
    main.setDimensions(new String[] { "x1" });
    QueryProfile referencedMain = new QueryProfile("referencedMain");
    // In both
    referencedMain.set("r1", "mainReferenced-r1", (QueryProfileRegistry) null);
    // Only in this
    referencedMain.set("r2", "mainReferenced-r2", (QueryProfileRegistry) null);
    QueryProfile referencedVariant = new QueryProfile("referencedVariant");
    // In both
    referencedVariant.set("r1", "variantReferenced-r1", (QueryProfileRegistry) null);
    // Only in this
    referencedVariant.set("r3", "variantReferenced-r3", (QueryProfileRegistry) null);
    main.set("a", referencedMain, (QueryProfileRegistry) null);
    main.set("a", referencedVariant, new String[] { "x1" }, null);
    Properties properties = new QueryProfileProperties(main.compile(null));
    // No context
    Map<String, Object> listed = properties.listProperties();
    assertEquals(2, listed.size());
    assertEquals("mainReferenced-r1", listed.get("a.r1"));
    assertEquals("mainReferenced-r2", listed.get("a.r2"));
    // Context x=x1
    listed = properties.listProperties(toMap(main, new String[] { "x1" }));
    assertEquals(3, listed.size());
    assertEquals("variantReferenced-r1", listed.get("a.r1"));
    assertEquals("mainReferenced-r2", listed.get("a.r2"));
    assertEquals("variantReferenced-r3", listed.get("a.r3"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Properties(com.yahoo.search.query.Properties) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

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