Search in sources :

Example 76 with QueryProfile

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

the class QueryProfileTypeInheritanceTestCase method testInheritance.

public void testInheritance() {
    type.inherited().add(user);
    type.freeze();
    user.freeze();
    assertFalse(type.isOverridable("myUserString"));
    assertEquals("myUserInteger", type.getField("myUserInteger").getName());
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    test.set("myUserInteger", "37", (QueryProfileRegistry) null);
    test.set("myUnknownInteger", "38", (QueryProfileRegistry) null);
    CompiledQueryProfile ctest = test.compile(null);
    assertEquals(37, ctest.get("myUserInteger"));
    assertEquals("38", 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 77 with QueryProfile

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

the class CloningTestCase method testReAssignment.

public void testReAssignment() {
    QueryProfile test = new QueryProfile("test");
    test.setDimensions(new String[] { "x" });
    test.freeze();
    Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
    q1.properties().set("a", "a1");
    q1.properties().set("a", "a2");
    assertEquals("a2", q1.properties().get("a"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query)

Example 78 with QueryProfile

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

the class CloningTestCase method testThreeLevelsOfCloningMiddleFirstSetOrder2.

public void testThreeLevelsOfCloningMiddleFirstSetOrder2() {
    QueryProfile test = new QueryProfile("test");
    test.set("a", "config-a", (QueryProfileRegistry) null);
    test.freeze();
    Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
    Query q2 = q1.clone();
    Query q31 = q2.clone();
    Query q32 = q2.clone();
    q2.properties().set("a", "q2-a");
    q31.properties().set("a", "q31-a");
    q1.properties().set("a", "q1-a");
    assertEquals("q1-a", q1.properties().get("a").toString());
    assertEquals("q2-a", q2.properties().get("a").toString());
    assertEquals("q31-a", q31.properties().get("a").toString());
    assertEquals("config-a", q32.properties().get("a").toString());
    q1.properties().set("a", "q1-a-2");
    assertEquals("q1-a-2", q1.properties().get("a").toString());
    assertEquals("q2-a", q2.properties().get("a").toString());
    assertEquals("q31-a", q31.properties().get("a").toString());
    assertEquals("config-a", q32.properties().get("a").toString());
    q2.properties().set("a", "q2-a-2");
    assertEquals("q1-a-2", q1.properties().get("a").toString());
    assertEquals("q2-a-2", q2.properties().get("a").toString());
    assertEquals("q31-a", q31.properties().get("a").toString());
    assertEquals("config-a", q32.properties().get("a").toString());
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query)

Example 79 with QueryProfile

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

the class CloningTestCase method testShallowCloning.

public void testShallowCloning() {
    QueryProfile test = new QueryProfile("test");
    test.freeze();
    Query q1 = new Query(HttpRequest.createTestRequest("?query=q", Method.GET), test.compile(null));
    q1.properties().set("a", new MutableString("a1"));
    Query q2 = q1.clone();
    ((MutableString) q2.properties().get("a")).set("a2");
    assertEquals("a2", q1.properties().get("a").toString());
    assertEquals("a2", q2.properties().get("a").toString());
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query)

Example 80 with QueryProfile

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

the class CloningTestCase method testCloningWithVariants.

public void testCloningWithVariants() {
    QueryProfile test = new QueryProfile("test");
    test.setDimensions(new String[] { "x" });
    test.freeze();
    Query q1 = new Query(HttpRequest.createTestRequest("?query=q&x=x1", Method.GET), test.compile(null));
    q1.properties().set("a", "a1");
    Query q2 = q1.clone();
    q2.properties().set("a", "a2");
    assertEquals("a1", q1.properties().get("a"));
    assertEquals("a2", q2.properties().get("a"));
}
Also used : 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