Search in sources :

Example 11 with Properties

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

the class QueryProfileVariantsTestCase method testQueryProfileReferencesWithSubstitution.

public void testQueryProfileReferencesWithSubstitution() {
    QueryProfile main = new QueryProfile("main");
    main.setDimensions(new String[] { "x1" });
    QueryProfile referencedMain = new QueryProfile("referencedMain");
    // In both
    referencedMain.set("r1", "%{prefix}mainReferenced-r1", (QueryProfileRegistry) null);
    // Only in this
    referencedMain.set("r2", "%{prefix}mainReferenced-r2", (QueryProfileRegistry) null);
    QueryProfile referencedVariant = new QueryProfile("referencedVariant");
    // In both
    referencedVariant.set("r1", "%{prefix}variantReferenced-r1", (QueryProfileRegistry) null);
    // Only in this
    referencedVariant.set("r3", "%{prefix}variantReferenced-r3", (QueryProfileRegistry) null);
    main.set("a", referencedMain, (QueryProfileRegistry) null);
    main.set("a", referencedVariant, new String[] { "x1" }, null);
    main.set("prefix", "mainPrefix:", (QueryProfileRegistry) null);
    main.set("prefix", "variantPrefix:", new String[] { "x1" }, null);
    Properties properties = new QueryProfileProperties(main.compile(null));
    // No context
    Map<String, Object> listed = properties.listProperties();
    assertEquals(3, listed.size());
    assertEquals("mainPrefix:mainReferenced-r1", listed.get("a.r1"));
    assertEquals("mainPrefix:mainReferenced-r2", listed.get("a.r2"));
    // Context x=x1
    listed = properties.listProperties(toMap(main, new String[] { "x1" }));
    assertEquals(4, listed.size());
    assertEquals("variantPrefix:variantReferenced-r1", listed.get("a.r1"));
    assertEquals("variantPrefix:mainReferenced-r2", listed.get("a.r2"));
    assertEquals("variantPrefix:variantReferenced-r3", listed.get("a.r3"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Properties(com.yahoo.search.query.Properties) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 12 with Properties

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

the class QueryProfileVariantsTestCase method testListVariantPropertiesCompounds1Simplified.

public void testListVariantPropertiesCompounds1Simplified() {
    QueryProfile main = new QueryProfile("main");
    main.setDimensions(new String[] { "x", "y" });
    main.set("a.p1", "main-a-x1", new String[] { "x1" }, null);
    QueryProfile inheritedVariant1 = new QueryProfile("inheritedVariant1");
    inheritedVariant1.set("a.p1", "inheritedVariant1-a", (QueryProfileRegistry) null);
    main.addInherited(inheritedVariant1, new String[] { "x1" });
    Properties properties = new QueryProfileProperties(main.compile(null));
    // Context x=x1
    Map<String, Object> listed = properties.listProperties(toMap(main, new String[] { "x1" }));
    assertEquals("main-a-x1", listed.get("a.p1"));
}
Also used : CompiledQueryProfile(com.yahoo.search.query.profile.compiled.CompiledQueryProfile) QueryProfile(com.yahoo.search.query.profile.QueryProfile) BackedOverridableQueryProfile(com.yahoo.search.query.profile.BackedOverridableQueryProfile) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties) Properties(com.yahoo.search.query.Properties) QueryProfileProperties(com.yahoo.search.query.profile.QueryProfileProperties)

Example 13 with Properties

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

the class XmlReadingTestCase method testSystemtest.

/**
 * Tests a subset of the configuration in the system test of this
 */
@Test
public void testSystemtest() {
    String queryString = "?query=test";
    QueryProfileXMLReader reader = new QueryProfileXMLReader();
    CompiledQueryProfileRegistry registry = reader.read("src/test/java/com/yahoo/search/query/profile/config/test/systemtest/").compile();
    HttpRequest request = HttpRequest.createTestRequest(queryString, Method.GET);
    CompiledQueryProfile profile = registry.findQueryProfile("default");
    Query query = new Query(request, profile);
    Properties p = query.properties();
    assertEquals("test", query.getModel().getQueryString());
    assertEquals("test", p.get("query"));
    assertEquals("test", p.get("QueRY"));
    assertEquals("test", p.get("model.queryString"));
    assertEquals("bar", p.get("foo"));
    assertEquals(5, p.get("hits"));
    assertEquals("tit", p.get("subst"));
    assertEquals("le", p.get("subst.end"));
    assertEquals("title", p.get("model.defaultIndex"));
    Map<String, Object> ps = p.listProperties();
    assertEquals(6, ps.size());
    assertEquals("bar", ps.get("foo"));
    assertEquals("5", ps.get("hits"));
    assertEquals("tit", ps.get("subst"));
    assertEquals("le", ps.get("subst.end"));
    assertEquals("title", ps.get("model.defaultIndex"));
    assertEquals("test", ps.get("model.queryString"));
}
Also used : HttpRequest(com.yahoo.container.jdisc.HttpRequest) 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) Properties(com.yahoo.search.query.Properties) Test(org.junit.Test)

Aggregations

Properties (com.yahoo.search.query.Properties)13 QueryProfileProperties (com.yahoo.search.query.profile.QueryProfileProperties)9 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)9 BackedOverridableQueryProfile (com.yahoo.search.query.profile.BackedOverridableQueryProfile)8 QueryProfile (com.yahoo.search.query.profile.QueryProfile)8 QueryProperties (com.yahoo.search.query.properties.QueryProperties)2 HttpRequest (com.yahoo.container.jdisc.HttpRequest)1 Query (com.yahoo.search.Query)1 PropagateSourceProperties (com.yahoo.search.federation.StrictContractsConfig.PropagateSourceProperties)1 ModelObjectMap (com.yahoo.search.query.profile.ModelObjectMap)1 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)1 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)1 DefaultProperties (com.yahoo.search.query.properties.DefaultProperties)1 PropertyMap (com.yahoo.search.query.properties.PropertyMap)1 RequestContextProperties (com.yahoo.search.query.properties.RequestContextProperties)1 SubProperties (com.yahoo.search.query.properties.SubProperties)1 Test (org.junit.Test)1