Search in sources :

Example 21 with QueryProfile

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

the class QueryProfileTestCase method testInheritance2Level.

public void testInheritance2Level() {
    QueryProfile barn = new QueryProfile("barn");
    QueryProfile mor = new QueryProfile("mor");
    QueryProfile far = new QueryProfile("far");
    QueryProfile mormor = new QueryProfile("mormor");
    QueryProfile morfar = new QueryProfile("morfar");
    QueryProfile farfar = new QueryProfile("farfar");
    barn.addInherited(mor);
    barn.addInherited(far);
    mor.addInherited(mormor);
    mor.addInherited(morfar);
    far.addInherited(farfar);
    morfar.set("a.x", "morfar-a", (QueryProfileRegistry) null);
    mormor.set("a.x", "mormor-a", (QueryProfileRegistry) null);
    farfar.set("a.x", "farfar-a", (QueryProfileRegistry) null);
    mor.set("a.x", "mor-a", (QueryProfileRegistry) null);
    far.set("a.x", "far-a", (QueryProfileRegistry) null);
    barn.set("a.x", "barn-a", (QueryProfileRegistry) null);
    mormor.set("b.x", "mormor-b", (QueryProfileRegistry) null);
    far.set("b.x", "far-b", (QueryProfileRegistry) null);
    mor.set("c.x", "mor-c", (QueryProfileRegistry) null);
    far.set("c.x", "far-c", (QueryProfileRegistry) null);
    mor.set("d.a.x", "mor-d.a", (QueryProfileRegistry) null);
    barn.set("d.b.x", "barn-d.b", (QueryProfileRegistry) null);
    QueryProfile annetBarn = new QueryProfile("annetBarn");
    annetBarn.set("venn", barn, (QueryProfileRegistry) null);
    CompiledQueryProfile cbarn = barn.compile(null);
    CompiledQueryProfile cannetBarn = annetBarn.compile(null);
    assertEquals("barn-a", cbarn.get("a.x"));
    assertEquals("mormor-b", cbarn.get("b.x"));
    assertEquals("mor-c", cbarn.get("c.x"));
    assertEquals("barn-a", cannetBarn.get("venn.a.x"));
    assertEquals("mormor-b", cannetBarn.get("venn.b.x"));
    assertEquals("mor-c", cannetBarn.get("venn.c.x"));
    assertEquals("barn-d.b", cbarn.get("d.b.x"));
    assertEquals("mor-d.a", cbarn.get("d.a.x"));
}
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 22 with QueryProfile

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

the class QueryProfileTestCase method testInheritance3Level.

public void testInheritance3Level() {
    QueryProfile barn = new QueryProfile("barn");
    QueryProfile mor = new QueryProfile("mor");
    QueryProfile far = new QueryProfile("far");
    QueryProfile mormor = new QueryProfile("mormor");
    QueryProfile morfar = new QueryProfile("morfar");
    QueryProfile farfar = new QueryProfile("farfar");
    barn.addInherited(mor);
    barn.addInherited(far);
    mor.addInherited(mormor);
    mor.addInherited(morfar);
    far.addInherited(farfar);
    morfar.set("y.a.x", "morfar-a", (QueryProfileRegistry) null);
    mormor.set("y.a.x", "mormor-a", (QueryProfileRegistry) null);
    farfar.set("y.a.x", "farfar-a", (QueryProfileRegistry) null);
    mor.set("y.a.x", "mor-a", (QueryProfileRegistry) null);
    far.set("y.a.x", "far-a", (QueryProfileRegistry) null);
    barn.set("y.a.x", "barn-a", (QueryProfileRegistry) null);
    mormor.set("y.b.x", "mormor-b", (QueryProfileRegistry) null);
    far.set("y.b.x", "far-b", (QueryProfileRegistry) null);
    mor.set("y.c.x", "mor-c", (QueryProfileRegistry) null);
    far.set("y.c.x", "far-c", (QueryProfileRegistry) null);
    mor.set("y.d.a.x", "mor-d.a", (QueryProfileRegistry) null);
    barn.set("y.d.b.x", "barn-d.b", (QueryProfileRegistry) null);
    QueryProfile annetBarn = new QueryProfile("annetBarn");
    annetBarn.set("venn", barn, (QueryProfileRegistry) null);
    CompiledQueryProfile cbarn = barn.compile(null);
    CompiledQueryProfile cannetBarn = annetBarn.compile(null);
    assertEquals("barn-a", cbarn.get("y.a.x"));
    assertEquals("mormor-b", cbarn.get("y.b.x"));
    assertEquals("mor-c", cbarn.get("y.c.x"));
    assertEquals("barn-a", cannetBarn.get("venn.y.a.x"));
    assertEquals("mormor-b", cannetBarn.get("venn.y.b.x"));
    assertEquals("mor-c", cannetBarn.get("venn.y.c.x"));
    assertEquals("barn-d.b", cbarn.get("y.d.b.x"));
    assertEquals("mor-d.a", cbarn.get("y.d.a.x"));
}
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 23 with QueryProfile

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

the class QueryProfileTestCase method testSettingNonLeaf3b.

public void testSettingNonLeaf3b() {
    QueryProfile p = new QueryProfile("test");
    p.setDimensions(new String[] { "x" });
    p.set("a", "a-value", new String[] { "x1" }, null);
    p.set("a.b", "a.b-value", (QueryProfileRegistry) null);
    QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
    assertNull(cp.get("a"));
    assertEquals("a.b-value", cp.get("a.b"));
    assertEquals("a-value", cp.get("a", QueryProfileVariantsTestCase.toMap(p, new String[] { "x1" })));
    assertEquals("a.b-value", cp.get("a.b", new String[] { "x1" }));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 24 with QueryProfile

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

the class QueryProfileTestCase method testRankTypeNames.

public void testRankTypeNames() {
    QueryProfile p = new QueryProfile("test");
    p.set("a.$b", "foo", (QueryProfileRegistry) null);
    p.set("a.query(b)", "bar", (QueryProfileRegistry) null);
    p.set("a.b.default-index", "fuu", (QueryProfileRegistry) null);
    CompiledQueryProfile cp = p.compile(null);
    assertEquals("foo", cp.get("a.$b"));
    assertEquals("bar", cp.get("a.query(b)"));
    assertEquals("fuu", cp.get("a.b.default-index"));
    Map<String, Object> p1 = cp.listValues("");
    assertEquals("foo", p1.get("a.$b"));
    assertEquals("bar", p1.get("a.query(b)"));
    assertEquals("fuu", p1.get("a.b.default-index"));
    Map<String, Object> p2 = cp.listValues("a");
    assertEquals("foo", p2.get("$b"));
    assertEquals("bar", p2.get("query(b)"));
    assertEquals("fuu", p2.get("b.default-index"));
}
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 25 with QueryProfile

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

the class QueryProfileTestCase method testQueryProfileInlineValueReassignment.

public void testQueryProfileInlineValueReassignment() {
    QueryProfile p = new QueryProfile("test");
    p.set("source.rel.params.query", "%{model.queryString}", (QueryProfileRegistry) null);
    p.freeze();
    Query q = new Query(HttpRequest.createTestRequest("?query=foo", Method.GET), p.compile(null));
    assertEquals("foo", q.properties().get("source.rel.params.query"));
    assertEquals("foo", q.properties().listProperties().get("source.rel.params.query"));
    q.getModel().setQueryString("bar");
    assertEquals("bar", q.properties().get("source.rel.params.query"));
    // Is still foo because model variables are not supported with the list function
    assertEquals("foo", q.properties().listProperties().get("source.rel.params.query"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) 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