Search in sources :

Example 26 with QueryProfile

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

the class QueryProfileTestCase method testQueryProfileModelValueListing.

public void testQueryProfileModelValueListing() {
    QueryProfile p = new QueryProfile("test");
    p.freeze();
    Query q = new Query(HttpRequest.createTestRequest("?query=bar", Method.GET), p.compile(null));
    assertEquals("bar", q.properties().get("model.queryString"));
    assertEquals("bar", q.properties().listProperties().get("model.queryString"));
    q.getModel().setQueryString("baz");
    assertEquals("baz", q.properties().get("model.queryString"));
    // Is still bar because model variables are not supported with the list function
    assertEquals("bar", q.properties().listProperties().get("model.queryString"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query)

Example 27 with QueryProfile

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

the class QueryProfileTestCase method testSettingNonLeaf4b.

public void testSettingNonLeaf4b() {
    QueryProfile p = new QueryProfile("test");
    p.setDimensions(new String[] { "x" });
    p.set("a", "a-value", (QueryProfileRegistry) null);
    p.set("a.b", "a.b-value", new String[] { "x1" }, null);
    QueryProfileProperties cp = new QueryProfileProperties(p.compile(null));
    assertEquals("a-value", cp.get("a"));
    assertNull(cp.get("a.b"));
    assertEquals("a-value", cp.get("a", new String[] { "x1" }));
    assertEquals("a.b-value", cp.get("a.b", QueryProfileVariantsTestCase.toMap(p, 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 28 with QueryProfile

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

the class QueryProfileTestCase method testExplicitReferenceOverride.

/**
 * Tests having both an explicit reference and an override
 */
public void testExplicitReferenceOverride() {
    QueryProfile a1 = new QueryProfile("a1");
    a1.set("b", "a1.b", (QueryProfileRegistry) null);
    QueryProfile profile = new QueryProfile("test");
    profile.set("a", a1, (QueryProfileRegistry) null);
    profile.set("a.b", "a.b", (QueryProfileRegistry) null);
    assertEquals("a.b", profile.compile(null).get("a.b"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile)

Example 29 with QueryProfile

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

the class QueryProfileTestCase method testBasics.

public void testBasics() {
    QueryProfile profile = new QueryProfile("test");
    profile.set("a", "a-value", (QueryProfileRegistry) null);
    profile.set("b.c", "b.c-value", (QueryProfileRegistry) null);
    profile.set("d.e.f", "d.e.f-value", (QueryProfileRegistry) null);
    CompiledQueryProfile cprofile = profile.compile(null);
    assertEquals("a-value", cprofile.get("a"));
    assertEquals("b.c-value", cprofile.get("b.c"));
    assertEquals("d.e.f-value", cprofile.get("d.e.f"));
    assertNull(cprofile.get("nonexistent"));
    assertNull(cprofile.get("nested.nonexistent"));
    assertTrue(profile.lookup("b", null).getClass() == QueryProfile.class);
    assertTrue(profile.lookup("b", null).getClass() == QueryProfile.class);
}
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 30 with QueryProfile

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

the class QueryProfileTestCase method testQueryProfileInlineValueReassignmentSimpleName.

public void testQueryProfileInlineValueReassignmentSimpleName() {
    QueryProfile p = new QueryProfile("test");
    p.set("key", "%{model.queryString}", (QueryProfileRegistry) null);
    p.freeze();
    Query q = new Query(HttpRequest.createTestRequest("?query=foo", Method.GET), p.compile(null));
    assertEquals("foo", q.properties().get("key"));
    assertEquals("foo", q.properties().listProperties().get("key"));
    q.getModel().setQueryString("bar");
    assertEquals("bar", q.properties().get("key"));
    // Is still bar because model variables are not supported with the list function
    assertEquals("foo", q.properties().listProperties().get("key"));
}
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