Search in sources :

Example 1 with SubProperties

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

the class FederationSearcher method getSourceProperties.

/**
 * Returns the set of properties set for the source or provider given in the query (if any).
 *
 * If the query has not set sourceName or providerName, null will be returned
 */
public static Properties getSourceProperties(Query query) {
    String sourceName = query.properties().getString(SOURCENAME);
    String providerName = query.properties().getString(PROVIDERNAME);
    if (sourceName == null || providerName == null)
        return null;
    Properties sourceProperties = new SubProperties("source." + sourceName, query.properties());
    Properties providerProperties = new SubProperties("provider." + providerName, query.properties());
    sourceProperties.chain(providerProperties);
    return sourceProperties;
}
Also used : SubProperties(com.yahoo.search.query.properties.SubProperties) QueryProperties(com.yahoo.search.query.properties.QueryProperties) PropagateSourceProperties(com.yahoo.search.federation.StrictContractsConfig.PropagateSourceProperties) Properties(com.yahoo.search.query.Properties) SubProperties(com.yahoo.search.query.properties.SubProperties)

Example 2 with SubProperties

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

the class SubPropertiesTestCase method testSubProperties.

@Test
public void testSubProperties() {
    PropertyMap map = new PropertyMap() {

        {
            set("a.e", "1");
            set("a.f", 2);
            set("b.e", "3");
            set("f", 3);
            set("e", "2");
            set("d", "a");
        }
    };
    SubProperties sub = new SubProperties("a", map);
    assertEquals("1", sub.get("e"));
    assertEquals(2, sub.get("f"));
    assertNull(sub.get("d"));
    assertEquals(new HashSet<>(Arrays.asList("e", "f")), sub.listProperties("").keySet());
}
Also used : PropertyMap(com.yahoo.processing.request.properties.PropertyMap) SubProperties(com.yahoo.search.query.properties.SubProperties) Test(org.junit.Test)

Aggregations

SubProperties (com.yahoo.search.query.properties.SubProperties)2 PropertyMap (com.yahoo.processing.request.properties.PropertyMap)1 PropagateSourceProperties (com.yahoo.search.federation.StrictContractsConfig.PropagateSourceProperties)1 Properties (com.yahoo.search.query.Properties)1 QueryProperties (com.yahoo.search.query.properties.QueryProperties)1 Test (org.junit.Test)1