Search in sources :

Example 61 with QueryProfileRegistry

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

the class OverrideTestCase method testSimpleUnoverridable.

/**
 * Check that a simple non-overridable string cannot be overridden
 */
public void testSimpleUnoverridable() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    test.set("myString", "finalString", (QueryProfileRegistry) null);
    registry.register(test);
    registry.freeze();
    // Assert request assignment does not work
    Query query = new Query(HttpRequest.createTestRequest("?myString=newValue", Method.GET), registry.compile().getComponent("test"));
    assertEquals(0, query.errors().size());
    assertEquals("finalString", query.properties().get("myString"));
    // Assert direct assignment does not work
    query.properties().set("myString", "newValue");
    assertEquals("finalString", query.properties().get("myString"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 62 with QueryProfileRegistry

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

the class XmlReadingTestCase method testKlee.

@Test
public void testKlee() {
    QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/klee");
    QueryProfile pv = registry.getComponent("twitter_dd-us:0.2.4");
    assertEquals("0.2.4", pv.getId().getVersion().toString());
    assertEquals("[query profile 'production']", pv.inherited().toString());
    QueryProfile p = registry.getComponent("twitter_dd-us:0.0.0");
    // that is 0.0.0
    assertEquals("", p.getId().getVersion().toString());
    assertEquals("[query profile 'twitter_dd']", p.inherited().toString());
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 63 with QueryProfileRegistry

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

the class QueryFromProfileTestCase method testQueryFromProfile1.

public void testQueryFromProfile1() {
    QueryProfileRegistry registry = new QueryProfileRegistry();
    QueryProfile topLevel = new QueryProfile("topLevel");
    topLevel.setType(registry.getTypeRegistry().getComponent("native"));
    registry.register(topLevel);
    QueryProfile queryBest = new QueryProfile("querybest");
    queryBest.setType(registry.getTypeRegistry().getComponent("model"));
    queryBest.set("queryString", "best", registry);
    registry.register(queryBest);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    Query query = new Query(HttpRequest.createTestRequest("?model=querybest", Method.GET), cRegistry.getComponent("topLevel"));
    assertEquals("best", query.properties().get("model.queryString"));
    assertEquals("best", query.getModel().getQueryTree().toString());
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry)

Example 64 with QueryProfileRegistry

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

the class MandatoryTestCase method testMandatoryUserProfileSetInRequest.

/**
 * Here, no user query profile is referenced in the query profile, but one is chosen in the request
 */
@Test
public void testMandatoryUserProfileSetInRequest() {
    Fixture1 fixture = new Fixture1();
    QueryProfile test = new QueryProfile("test");
    test.setType(fixture.type);
    QueryProfile myUser = new QueryProfile("user");
    myUser.setType(fixture.user);
    myUser.set("myUserInteger", 1, null);
    QueryProfileRegistry registry = new QueryProfileRegistry();
    registry.register(test);
    registry.register(myUser);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    // Underspecified request 1
    assertError("Incomplete query: Parameter 'myUserQueryProfile' is mandatory in query profile 'test' of type 'testtype' but is not set", new Query(HttpRequest.createTestRequest("?myString=aString", Method.GET), cRegistry.getComponent("test")));
    // Underspecified request 1
    assertError("Incomplete query: Parameter 'myUserQueryProfile.myUserString' is mandatory in query profile 'test' of type 'testtype' but is not set", new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile=user", Method.GET), cRegistry.getComponent("test")));
    // Fully specified request
    assertError(null, new Query(HttpRequest.createTestRequest("?myString=aString&myUserQueryProfile=user&myUserQueryProfile.myUserString=userString", Method.GET), cRegistry.getComponent("test")));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Test(org.junit.Test)

Example 65 with QueryProfileRegistry

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

the class MultiProfileTestCase method testValid.

public void testValid() {
    QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/multiprofile");
    QueryProfile multiprofile1 = registry.getComponent("multiprofile1");
    assertNotNull(multiprofile1);
    assertGet("general-a", "a", new String[] { null, null, null }, multiprofile1);
    assertGet("us-nokia-test1-a", "a", new String[] { "us", "nok ia", "test1" }, multiprofile1);
    assertGet("us-nokia-b", "b", new String[] { "us", "nok ia", "test1" }, multiprofile1);
    assertGet("us-a", "a", new String[] { "us", null, null }, multiprofile1);
    assertGet("us-b", "b", new String[] { "us", null, null }, multiprofile1);
    assertGet("us-nokia-a", "a", new String[] { "us", "nok ia", null }, multiprofile1);
    assertGet("us-test1-a", "a", new String[] { "us", null, "test1" }, multiprofile1);
    assertGet("us-test1-b", "b", new String[] { "us", null, "test1" }, multiprofile1);
    assertGet("us-a", "a", new String[] { "us", "unspecified", "unspecified" }, multiprofile1);
    assertGet("us-nokia-a", "a", new String[] { "us", "nok ia", "unspecified" }, multiprofile1);
    assertGet("us-test1-a", "a", new String[] { "us", "unspecified", "test1" }, multiprofile1);
    assertGet("us-nokia-b", "b", new String[] { "us", "nok ia", "test1" }, multiprofile1);
    // ...inherited
    assertGet("parent1-value", "parent1", new String[] { "us", "nok ia", "-" }, multiprofile1);
    assertGet("parent2-value", "parent2", new String[] { "us", "nok ia", "-" }, multiprofile1);
    assertGet(null, "parent1", new String[] { "us", "-", "-" }, multiprofile1);
    assertGet(null, "parent2", new String[] { "us", "-", "-" }, multiprofile1);
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader)

Aggregations

QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)68 Test (org.junit.Test)38 QueryProfile (com.yahoo.search.query.profile.QueryProfile)24 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)16 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)16 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)14 Query (com.yahoo.search.Query)11 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)11 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)11 Pair (com.yahoo.collections.Pair)8 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)8 Search (com.yahoo.searchdefinition.Search)8 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)6 SDField (com.yahoo.searchdefinition.document.SDField)5 ComponentId (com.yahoo.component.ComponentId)4 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4