Search in sources :

Example 21 with QueryProfileXMLReader

use of com.yahoo.search.query.profile.config.QueryProfileXMLReader 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 22 with QueryProfileXMLReader

use of com.yahoo.search.query.profile.config.QueryProfileXMLReader 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 23 with QueryProfileXMLReader

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

the class XmlReadingTestCase method testInvalid1.

@Test
public void testInvalid1() {
    try {
        new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/invalidxml1");
        fail("Should have failed");
    } catch (IllegalArgumentException e) {
        assertEquals("Error reading query profile 'illegalSetting' of type 'native': Could not set 'model.notDeclared' to 'value': 'notDeclared' is not declared in query profile type 'model', and the type is strict", Exceptions.toMessageString(e));
    }
}
Also used : QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Aggregations

QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)23 Test (org.junit.Test)21 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)14 Query (com.yahoo.search.Query)13 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)5 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)4 HttpRequest (com.yahoo.container.jdisc.HttpRequest)3 QueryProfile (com.yahoo.search.query.profile.QueryProfile)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 CompoundName (com.yahoo.processing.request.CompoundName)1 Properties (com.yahoo.search.query.Properties)1 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)1 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)1 File (java.io.File)1