Search in sources :

Example 6 with QueryProfileXMLReader

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

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

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

Example 9 with QueryProfileXMLReader

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

the class XmlReadingTestCase method testQueryProfileVariants2.

@Test
public void testQueryProfileVariants2() {
    CompiledQueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/search/query/profile/config/test/queryprofilevariants2").compile();
    CompiledQueryProfile multi = registry.getComponent("multi");
    {
        Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi", Method.GET), multi);
        query.validate();
        assertEquals("best", query.properties().get("model.queryString"));
        assertEquals("best", query.getModel().getQueryString());
    }
    {
        Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default", Method.GET), multi);
        query.validate();
        assertEquals("best", query.properties().get("model.queryString"));
        assertEquals("best", query.getModel().getQueryString());
        assertEquals("default", query.getModel().getDefaultIndex());
    }
    {
        Query query = new Query(HttpRequest.createTestRequest("?queryProfile=multi&myindex=default&myquery=love", Method.GET), multi);
        query.validate();
        assertEquals("love", query.properties().get("model.queryString"));
        assertEquals("love", query.getModel().getQueryString());
        assertEquals("default", query.getModel().getDefaultIndex());
    }
    {
        Query query = new Query(HttpRequest.createTestRequest("?model=querybest", Method.GET), multi);
        query.validate();
        assertEquals("best", query.getModel().getQueryString());
        assertEquals("title", query.properties().get("model.defaultIndex"));
        assertEquals("title", query.getModel().getDefaultIndex());
    }
}
Also used : CompiledQueryProfileRegistry(com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry) CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 10 with QueryProfileXMLReader

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

the class DumpTool method dump.

private String dump(String profileName, String dir, String parameters) {
    // Import profiles
    if (dir.isEmpty())
        dir = ".";
    File dirInAppPackage = new File(dir, "search/query-profiles");
    if (dirInAppPackage.exists())
        dir = dirInAppPackage.getPath();
    QueryProfileXMLReader reader = new QueryProfileXMLReader();
    QueryProfileRegistry registry = reader.read(dir);
    registry.freeze();
    // Dump (through query to get wiring & parameter parsing done easily)
    Query query = new Query("?" + parameters, registry.compile().findQueryProfile(profileName));
    Map<String, Object> properties = query.properties().listProperties();
    // Create result
    StringBuilder b = new StringBuilder();
    for (Map.Entry<String, Object> property : properties.entrySet()) {
        b.append(property.getKey());
        b.append("=");
        b.append(property.getValue().toString());
        b.append("\n");
    }
    return b.toString();
}
Also used : Query(com.yahoo.search.Query) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) File(java.io.File) Map(java.util.Map)

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