Search in sources :

Example 1 with CompiledQueryProfileRegistry

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

the class XmlReadingTestCase method testNewsCase2.

@Test
public void testNewsCase2() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase2").compile();
    Query query;
    query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET), registry.getComponent("default"));
    assertEquals("0.0", query.properties().get("a.features.b"));
    assertEquals("0.0", query.properties().listProperties().get("a.features.b"));
    query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent&custid_2=child", Method.GET), registry.getComponent("default"));
    assertEquals("0.1", query.properties().get("a.features.b"));
    assertEquals("0.1", query.properties().listProperties().get("a.features.b"));
}
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 2 with CompiledQueryProfileRegistry

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

the class XmlReadingTestCase method testNewsCase3.

@Test
public void testNewsCase3() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase3").compile();
    Query query;
    query = new Query(HttpRequest.createTestRequest("?query=test&custid_1=parent", Method.GET), registry.getComponent("default"));
    assertEquals("0.0", query.properties().get("a.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("a.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 3 with CompiledQueryProfileRegistry

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

the class XmlReadingTestCase method testNewsCase1.

@Test
public void testNewsCase1() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newscase1").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.b"));
    assertEquals("0.0", query.properties().listProperties().get("ranking.features.b"));
    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.b"));
    assertEquals("0.1", query.properties().listProperties().get("ranking.features.b"));
}
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 4 with CompiledQueryProfileRegistry

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

the class XmlReadingTestCase method testSourceProvider.

@Test
public void testSourceProvider() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/sourceprovider").compile();
    String queryString = "tiled?query=india&queryProfile=myprofile&source.common.intl=tw&source.common.mode=adv";
    Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("myprofile"));
    for (Map.Entry e : query.properties().listProperties().entrySet()) System.out.println(e);
    assertEquals("news", query.properties().listProperties().get("source.common.provider"));
    assertEquals("news", query.properties().get("source.common.provider"));
}
Also used : CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 5 with CompiledQueryProfileRegistry

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

the class XmlReadingTestCase method testNewsFE1.

@Test
public void testNewsFE1() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/newsfe").compile();
    String queryString = "tiled?vertical=news&query=barack&intl=us&resulttypes=article&testid=&clientintl=us&SpellState=&rss=0&tracelevel=5";
    Query query = new Query(HttpRequest.createTestRequest(queryString, Method.GET), registry.getComponent("default"));
    assertEquals("13", query.properties().listProperties().get("source.news.discovery.sources.count"));
    assertEquals("13", query.properties().get("source.news.discovery.sources.count"));
    assertEquals("sources", query.properties().listProperties().get("source.news.discovery"));
    assertEquals("sources", query.properties().get("source.news.discovery"));
}
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)

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