Search in sources :

Example 31 with CompiledQueryProfileRegistry

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

the class XmlReadingTestCase method testNewsFE2.

@Test
public void testNewsFE2() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe2").compile();
    String queryString = "tiled?query=a&intl=tw&mode=adv&mode=adv";
    Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
    assertEquals("news_adv", query.properties().listProperties().get("provider"));
    assertEquals("news_adv", query.properties().get("provider"));
}
Also used : CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 32 with CompiledQueryProfileRegistry

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

the class XmlReadingTestCase method testNewsCase4.

// Should cause an exception on the first line as we are trying to create a profile setting an illegal value in "ranking"
@Test
public void testNewsCase4() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase4").compile();
    Query query;
    query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET), registry.getComponent("default"));
    assertEquals("0.0", query.properties().get("ranking.features"));
    query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET), registry.getComponent("default"));
    assertEquals("0.1", query.properties().get("ranking.features"));
}
Also used : CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 33 with CompiledQueryProfileRegistry

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

the class QueryProfileTypeTestCase method testSettingValueInStrictTypeNestedUnderUntypedMaps.

/**
 * Tests setting a illegal value in a strict profile nested under untyped maps
 */
public void testSettingValueInStrictTypeNestedUnderUntypedMaps() {
    QueryProfile topMap = new QueryProfile("topMap");
    QueryProfile subMap = new QueryProfile("topSubMap");
    topMap.set("subMap", subMap, registry);
    QueryProfile test = new QueryProfile("test");
    test.setType(typeStrict);
    subMap.set("typeProfile", test, registry);
    registry.register(topMap);
    registry.register(subMap);
    registry.register(test);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    try {
        new Query(HttpRequest.createTestRequest("?subMap.typeProfile.someValue=value", com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("topMap"));
        fail("Above statement should throw");
    } catch (QueryException e) {
        // As expected.
        assertThat(Exceptions.toMessageString(e), containsString("Could not set 'subMap.typeProfile.someValue' to 'value': 'someValue' is not declared in query profile type 'testtypeStrict', and the type is strict"));
    }
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) QueryException(com.yahoo.prelude.query.QueryException) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query)

Example 34 with CompiledQueryProfileRegistry

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

the class QueryProfileTypeTestCase method testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile.

/**
 * Tests overriding a subprofile as an id string through the query.
 * Here, no user profile is set before it is assigned in the query
 * The whole thing is accessed through a two levels of nontyped top-level profiles
 */
public void testTypedSettingOfQueryProfileReferencesNonStrictThroughQueryNestedInAnUntypedProfile() {
    QueryProfile topMap = new QueryProfile("topMap");
    QueryProfile subMap = new QueryProfile("topSubMap");
    topMap.set("subMap", subMap, registry);
    QueryProfile test = new QueryProfile("test");
    test.setType(type);
    subMap.set("typeProfile", test, registry);
    QueryProfile newUser = new QueryProfile("newUser");
    newUser.setType(user);
    newUser.set("myUserString", "newUserValue1", registry);
    newUser.set("myUserInteger", 845, registry);
    registry.register(topMap);
    registry.register(subMap);
    registry.register(test);
    registry.register(newUser);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    Query query = new Query(HttpRequest.createTestRequest("?subMap.typeProfile.myUserQueryProfile=newUser", com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("topMap"));
    assertEquals(0, query.errors().size());
    assertEquals("newUserValue1", query.properties().get("subMap.typeProfile.myUserQueryProfile.myUserString"));
    assertEquals(845, query.properties().get("subMap.typeProfile.myUserQueryProfile.myUserInteger"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query)

Example 35 with CompiledQueryProfileRegistry

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

the class QueryProfileTypeTestCase method testTensorRankFeatureInRequest.

public void testTensorRankFeatureInRequest() throws UnsupportedEncodingException {
    QueryProfile profile = new QueryProfile("test");
    profile.setType(type);
    registry.register(profile);
    CompiledQueryProfileRegistry cRegistry = registry.compile();
    String tensorString = "{{a:a1, b:b1}:1.0, {a:a2, b:b1}:2.0}}";
    Query query = new Query(HttpRequest.createTestRequest("?" + encode("ranking.features.query(myTensor1)") + "=" + encode(tensorString), com.yahoo.jdisc.http.HttpRequest.Method.GET), cRegistry.getComponent("test"));
    assertEquals(0, query.errors().size());
    assertEquals(Tensor.from(tensorString), query.properties().get("ranking.features.query(myTensor1)"));
    assertEquals(Tensor.from(tensorString), query.getRanking().getFeatures().getTensor("query(myTensor1)").get());
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString)

Aggregations

CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)35 Query (com.yahoo.search.Query)33 QueryProfile (com.yahoo.search.query.profile.QueryProfile)22 Test (org.junit.Test)21 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)15 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)12 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)7 HttpRequest (com.yahoo.container.jdisc.HttpRequest)3 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)3 QueryProfileConfigurer (com.yahoo.search.query.profile.config.QueryProfileConfigurer)2 HashMap (java.util.HashMap)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 QueryException (com.yahoo.prelude.query.QueryException)1 CompoundName (com.yahoo.processing.request.CompoundName)1 Properties (com.yahoo.search.query.Properties)1 QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)1 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)1 Map (java.util.Map)1