Search in sources :

Example 6 with AttributeFields

use of com.yahoo.searchdefinition.derived.AttributeFields in project vespa by vespa-engine.

the class RankingExpressionShadowingTestCase method testBasicMacroShadowing.

@Test
public void testBasicMacroShadowing() throws ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
    builder.importString("search test {\n" + "    document test { \n" + "        field a type string { \n" + "            indexing: index \n" + "        }\n" + "    }\n" + "    \n" + "    rank-profile test {\n" + "        macro sin(x) {\n" + "            expression: x * x\n" + "        }\n" + "        first-phase {\n" + "            expression: sin(2)\n" + "        }\n" + "    }\n" + "\n" + "}\n");
    builder.build();
    Search s = builder.getSearch();
    RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(new QueryProfileRegistry());
    List<Pair<String, String>> testRankProperties = new RawRankProfile(test, new QueryProfileRegistry(), new AttributeFields(s)).configProperties();
    assertEquals("(rankingExpression(sin).rankingScript,x * x)", testRankProperties.get(0).toString());
    assertEquals("(rankingExpression(sin@).rankingScript,2 * 2)", censorBindingHash(testRankProperties.get(1).toString()));
    assertEquals("(vespa.rank.firstphase,rankingExpression(sin@))", censorBindingHash(testRankProperties.get(2).toString()));
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields) Pair(com.yahoo.collections.Pair) Test(org.junit.Test)

Example 7 with AttributeFields

use of com.yahoo.searchdefinition.derived.AttributeFields in project vespa by vespa-engine.

the class TensorTransformTestCase method buildSearch.

private List<Pair<String, String>> buildSearch(String expression) throws ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    QueryProfileRegistry queryProfiles = setupQueryProfileTypes();
    SearchBuilder builder = new SearchBuilder(rankProfileRegistry, queryProfiles);
    builder.importString("search test {\n" + "    document test { \n" + "        field double_field type double { \n" + "            indexing: summary | attribute \n" + "        }\n" + "        field double_array_field type array<double> { \n" + "            indexing: summary | attribute \n" + "        }\n" + "        field weightedset_field type weightedset<double> { \n" + "            indexing: summary | attribute \n" + "        }\n" + "        field tensor_field_1 type tensor(x{}) { \n" + "            indexing: summary | attribute \n" + "            attribute: tensor(x{}) \n" + "        }\n" + "        field tensor_field_2 type tensor(x[3],y[3]) { \n" + "            indexing: summary | attribute \n" + "            attribute: tensor(x[3],y[3]) \n" + "        }\n" + "    }\n" + "    constant file_constant_tensor {\n" + "        file: constants/tensor.json\n" + "        type: tensor(x{})\n" + "    }\n" + "    rank-profile base {\n" + "        constants {\n" + "            base_constant_tensor {\n" + "                value: { {x:0}:0 }\n" + "            }\n" + "        }\n" + "        macro base_tensor() {\n" + "            expression: constant(base_constant_tensor)\n" + "        }\n" + "    }\n" + "    rank-profile test inherits base {\n" + "        constants {\n" + "            test_constant_tensor {\n" + "                value: { {x:0}:1 }\n" + "            }\n" + "        }\n" + "        macro returns_tensor_with_arg(arg1) {\n" + "            expression: 2.0 * arg1\n" + "        }\n" + "        macro wraps_returns_tensor() {\n" + "            expression: returns_tensor\n" + "        }\n" + "        macro returns_tensor() {\n" + "            expression: attribute(tensor_field_2)\n" + "        }\n" + "        macro tensor_inheriting() {\n" + "            expression: base_tensor\n" + "        }\n" + "        macro testexpression() {\n" + "            expression: " + expression + "\n" + "        }\n" + "    }\n" + "}\n");
    builder.build(true, new BaseDeployLogger());
    Search s = builder.getSearch();
    RankProfile test = rankProfileRegistry.getRankProfile(s, "test").compile(queryProfiles);
    List<Pair<String, String>> testRankProperties = new RawRankProfile(test, queryProfiles, new AttributeFields(s)).configProperties();
    return testRankProperties;
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields) Pair(com.yahoo.collections.Pair)

Example 8 with AttributeFields

use of com.yahoo.searchdefinition.derived.AttributeFields in project vespa by vespa-engine.

the class RankProfileTestCase method assertQueryFeatureTypeSettings.

private static void assertQueryFeatureTypeSettings(RankProfile profile, Search search) {
    RawRankProfile rawProfile = new RawRankProfile(profile, new QueryProfileRegistry(), new AttributeFields(search));
    assertEquals("tensor(x[10])", findProperty(rawProfile.configProperties(), "vespa.type.query.tensor1").get());
    assertEquals("tensor(y{})", findProperty(rawProfile.configProperties(), "vespa.type.query.tensor2").get());
    assertFalse(findProperty(rawProfile.configProperties(), "vespa.type.query.tensor3").isPresent());
    assertFalse(findProperty(rawProfile.configProperties(), "vespa.type.query.numeric").isPresent());
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields)

Example 9 with AttributeFields

use of com.yahoo.searchdefinition.derived.AttributeFields in project vespa by vespa-engine.

the class RankProfileTestCase method testTermwiseLimitAndSomeMoreIncludingInheritance.

@Test
public void testTermwiseLimitAndSomeMoreIncludingInheritance() throws ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
    builder.importString("search test {\n" + "    document test { \n" + "        field a type string { \n" + "            indexing: index \n" + "        }\n" + "    }\n" + "    \n" + "    rank-profile parent {\n" + "        termwise-limit:0.78\n" + "        num-threads-per-search:8\n" + "        min-hits-per-thread:70\n" + "        num-search-partitions:1200\n" + "    }\n" + "    rank-profile child inherits parent { }" + "\n" + "}\n");
    builder.build();
    Search search = builder.getSearch();
    AttributeFields attributeFields = new AttributeFields(search);
    verifyRankProfile(rankProfileRegistry.getRankProfile(search, "parent"), attributeFields);
    verifyRankProfile(rankProfileRegistry.getRankProfile(search, "child"), attributeFields);
}
Also used : AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields) Test(org.junit.Test)

Example 10 with AttributeFields

use of com.yahoo.searchdefinition.derived.AttributeFields in project vespa by vespa-engine.

the class RankProfileTestCase method assertAttributeTypeSettings.

private static void assertAttributeTypeSettings(RankProfile profile, Search search) {
    RawRankProfile rawProfile = new RawRankProfile(profile, new QueryProfileRegistry(), new AttributeFields(search));
    assertEquals("tensor(x[10])", findProperty(rawProfile.configProperties(), "vespa.type.attribute.a").get());
    assertEquals("tensor(y{})", findProperty(rawProfile.configProperties(), "vespa.type.attribute.b").get());
    assertEquals("tensor(x[])", findProperty(rawProfile.configProperties(), "vespa.type.attribute.c").get());
}
Also used : RawRankProfile(com.yahoo.searchdefinition.derived.RawRankProfile) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) AttributeFields(com.yahoo.searchdefinition.derived.AttributeFields)

Aggregations

AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)12 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)11 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)11 Test (org.junit.Test)9 Pair (com.yahoo.collections.Pair)8 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 RankProfile (com.yahoo.searchdefinition.RankProfile)1 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)1 Search (com.yahoo.searchdefinition.Search)1 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)1