Search in sources :

Example 6 with RankProfileRegistry

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

the class IndexingScriptRewriterTestCase method processField.

private static ScriptExpression processField(SDField unprocessedField) {
    SDDocumentType sdoc = new SDDocumentType("test");
    sdoc.addField(unprocessedField);
    Search search = new Search("test", null);
    search.addDocument(sdoc);
    Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
    return unprocessedField.getIndexingScript();
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles)

Example 7 with RankProfileRegistry

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

the class ReservedMacroNamesTestCase method requireThatMacrosWithReservedNamesIssueAWarning.

@Test
public void requireThatMacrosWithReservedNamesIssueAWarning() throws ParseException {
    TestDeployLogger deployLogger = new TestDeployLogger();
    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_rank_profile {\n" + "        macro not_a_reserved_name(x) {\n" + "            expression: x + x\n" + "        }\n" + "        macro sigmoid(x) {\n" + "            expression: x * x\n" + "        }\n" + "        first-phase {\n" + "            expression: sigmoid(2) + not_a_reserved_name(1)\n" + "        }\n" + "    }\n" + "    rank-profile test_rank_profile_2 inherits test_rank_profile {\n" + "        macro sin(x) {\n" + "            expression: x * x\n" + "        }\n" + "        first-phase {\n" + "            expression: sigmoid(2) + sin(1)\n" + "        }\n" + "    }\n" + "}\n");
    builder.build(true, deployLogger);
    assertTrue(deployLogger.log.contains("sigmoid") && deployLogger.log.contains("test_rank_profile"));
    assertTrue(deployLogger.log.contains("sigmoid") && deployLogger.log.contains("test_rank_profile_2"));
    assertTrue(deployLogger.log.contains("sin") && deployLogger.log.contains("test_rank_profile_2"));
    assertFalse(deployLogger.log.contains("not_a_reserved_name") && deployLogger.log.contains("test_rank_profile"));
    assertFalse(deployLogger.log.contains("not_a_reserved_name") && deployLogger.log.contains("test_rank_profile_2"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) Test(org.junit.Test)

Example 8 with RankProfileRegistry

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

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

the class FastAccessValidatorTest method throws_exception_on_incompatible_use_of_fastaccess.

@Test
public void throws_exception_on_incompatible_use_of_fastaccess() throws ParseException {
    SearchBuilder builder = new SearchBuilder(new RankProfileRegistry());
    builder.importString(TestUtil.joinLines("search parent {", "  document parent {", "    field int_field type int { indexing: attribute }", "  }", "}"));
    builder.importString(TestUtil.joinLines("search test {", "    document test { ", "        field int_attribute type int { ", "            indexing: attribute ", "            attribute: fast-access", "        }", "        field predicate_attribute type predicate {", "            indexing: attribute ", "            attribute: fast-access", "        }", "        field tensor_attribute type tensor(x[]) {", "            indexing: attribute ", "            attribute: fast-access", "        }", "        field reference_attribute type reference<parent> {", "            indexing: attribute ", "            attribute: fast-access", "        }", "    }", "}"));
    exceptionRule.expect(IllegalArgumentException.class);
    exceptionRule.expectMessage("For search 'test': The following attributes have a type that is incompatible " + "with fast-access: predicate_attribute, tensor_attribute, reference_attribute. " + "Predicate, tensor and reference attributes are incompatible with fast-access.");
    builder.build();
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) Test(org.junit.Test)

Example 10 with RankProfileRegistry

use of com.yahoo.searchdefinition.RankProfileRegistry 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)

Aggregations

RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)16 Test (org.junit.Test)14 Search (com.yahoo.searchdefinition.Search)13 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)10 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)8 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)7 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)7 SDField (com.yahoo.searchdefinition.document.SDField)7 RankProfile (com.yahoo.searchdefinition.RankProfile)4 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)4 Pair (com.yahoo.collections.Pair)1 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)1 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)1