Search in sources :

Example 6 with RankProfile

use of com.yahoo.searchdefinition.RankProfile 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 7 with RankProfile

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

the class RankProfileList method deriveRankProfiles.

private void deriveRankProfiles(RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfiles, Search search, AttributeFields attributeFields) {
    RawRankProfile defaultProfile = new RawRankProfile(rankProfileRegistry.getRankProfile(search, "default"), queryProfiles, attributeFields);
    rankProfiles.put(defaultProfile.getName(), defaultProfile);
    for (RankProfile rank : rankProfileRegistry.localRankProfiles(search)) {
        if ("default".equals(rank.getName()))
            continue;
        RawRankProfile rawRank = new RawRankProfile(rank, queryProfiles, attributeFields);
        rankProfiles.put(rawRank.getName(), rawRank);
    }
}
Also used : RankProfile(com.yahoo.searchdefinition.RankProfile)

Example 8 with RankProfile

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

the class RankingExpressionTypeValidatorTestCase method testMacroInvocationTypes.

@Test
public void testMacroInvocationTypes() throws Exception {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
    builder.importString(joinLines("search test {", "  document test { ", "    field a type tensor(x[],y[]) {", "      indexing: attribute", "    }", "    field b type tensor(z[10]) {", "      indexing: attribute", "    }", "  }", "  rank-profile my_rank_profile {", "    macro macro1(attribute_to_use) {", "      expression: attribute(attribute_to_use)", "    }", "    summary-features {", "      macro1(a)", "      macro1(b)", "    }", "  }", "}"));
    builder.build();
    RankProfile profile = builder.getRankProfileRegistry().getRankProfile(builder.getSearch(), "my_rank_profile");
    assertEquals(TensorType.fromSpec("tensor(x[],y[])"), summaryFeatures(profile).get("macro1(a)").type(profile.typeContext(builder.getQueryProfileRegistry())));
    assertEquals(TensorType.fromSpec("tensor(z[10])"), summaryFeatures(profile).get("macro1(b)").type(profile.typeContext(builder.getQueryProfileRegistry())));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) RankProfile(com.yahoo.searchdefinition.RankProfile) Test(org.junit.Test)

Example 9 with RankProfile

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

the class LiteralBoostTestCase method testNonDefaultRankLiteralBoost.

/**
 * Tests adding a literal boost in a non-default rank profile only
 */
@Test
public void testNonDefaultRankLiteralBoost() {
    Search search = new Search("literalboost", null);
    RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
    SDDocumentType document = new SDDocumentType("literalboost");
    search.addDocument(document);
    SDField field1 = document.addField("a", DataType.STRING);
    field1.parseIndexingScript("{ index }");
    RankProfile other = new RankProfile("other", search, rankProfileRegistry);
    rankProfileRegistry.addRankProfile(other);
    other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333));
    search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry());
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    // Check il script addition
    assertIndexing(Arrays.asList("clear_state | guard { input a | tokenize normalize stem:\"SHORTEST\" | index a; }", "clear_state | guard { input a | tokenize | index a_literal; }"), search);
    // Check index info addition
    IndexInfo indexInfo = derived.getIndexInfo();
    assertTrue(indexInfo.hasCommand("a", "literal-boost"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) Test(org.junit.Test)

Example 10 with RankProfile

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

the class FilterFieldNames method process.

@Override
public void process(boolean validate) {
    for (SDField f : search.allConcreteFields()) {
        if (f.getRanking().isFilter()) {
            filterField(f.getName());
        }
    }
    for (RankProfile profile : rankProfileRegistry.localRankProfiles(search)) {
        Set<String> filterFields = new LinkedHashSet<>();
        findFilterFields(search, profile, filterFields);
        for (Iterator<String> itr = filterFields.iterator(); itr.hasNext(); ) {
            String fieldName = itr.next();
            profile.filterFields().add(fieldName);
            profile.addRankSetting(fieldName, RankProfile.RankSetting.Type.RANKTYPE, RankType.EMPTY);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SDField(com.yahoo.searchdefinition.document.SDField) RankProfile(com.yahoo.searchdefinition.RankProfile)

Aggregations

RankProfile (com.yahoo.searchdefinition.RankProfile)10 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)4 Test (org.junit.Test)4 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)3 Search (com.yahoo.searchdefinition.Search)3 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)3 SDField (com.yahoo.searchdefinition.document.SDField)3 TensorType (com.yahoo.tensor.TensorType)3 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)2 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)2 HashSet (java.util.HashSet)2 Pair (com.yahoo.collections.Pair)1 Path (com.yahoo.path.Path)1 RankingConstant (com.yahoo.searchdefinition.RankingConstant)1 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)1 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)1 RankingExpression (com.yahoo.searchlib.rankingexpression.RankingExpression)1 Reference (com.yahoo.searchlib.rankingexpression.Reference)1 ExpressionNode (com.yahoo.searchlib.rankingexpression.rule.ExpressionNode)1 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)1