Search in sources :

Example 51 with QueryProfileRegistry

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

the class RankingExpressionWithTensorFlowTestCase method testTensorFlowReferenceMissingMacro.

@Test
public void testTensorFlowReferenceMissingMacro() throws ParseException {
    try {
        RankProfileSearchFixture search = new RankProfileSearchFixture(new StoringApplicationPackage(applicationDir), new QueryProfileRegistry(), "  rank-profile my_profile {\n" + "    first-phase {\n" + "      expression: tensorflow('mnist_softmax/saved')" + "    }\n" + "  }");
        search.assertFirstPhaseExpression(vespaExpression, "my_profile");
        fail("Expecting exception");
    } catch (IllegalArgumentException expected) {
        assertEquals("Rank profile 'my_profile' is invalid: Could not use tensorflow model from " + "tensorflow('mnist_softmax/saved'): " + "Model refers Placeholder 'Placeholder' of type tensor(d0[],d1[784]) but this macro is " + "not present in rank profile 'my_profile'", Exceptions.toMessageString(expected));
    }
}
Also used : QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 52 with QueryProfileRegistry

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

the class QueryProfileVariantsTestCase method testConfigCreation2.

@Test
public void testConfigCreation2() throws IOException {
    QueryProfileRegistry registry = new QueryProfileXMLReader().read("src/test/java/com/yahoo/vespa/model/container/search/test/queryprofilevariants2");
    QueryProfiles profiles = new QueryProfiles(registry);
    assertSerializedConfigFileEquals(root + "query-profile-variants2-configuration.cfg", profiles.getConfig().toString());
}
Also used : QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) QueryProfileXMLReader(com.yahoo.search.query.profile.config.QueryProfileXMLReader) Test(org.junit.Test)

Example 53 with QueryProfileRegistry

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

the class SimpleInheritTestCase method testEmptyChild.

@Test
public void testEmptyChild() throws IOException, ParseException {
    String name = "emptychild";
    final String expectedResultsDirName = "src/test/derived/" + name + "/";
    SearchBuilder builder = new SearchBuilder();
    builder.importFile(expectedResultsDirName + "parent.sd");
    builder.importFile(expectedResultsDirName + "child.sd");
    builder.build();
    Search search = builder.getSearch("child");
    String toDirName = "temp/" + name;
    File toDir = new File(toDirName);
    toDir.mkdirs();
    deleteContent(toDir);
    DerivedConfiguration config = new DerivedConfiguration(search, builder.getRankProfileRegistry(), new QueryProfileRegistry());
    config.export(toDirName);
    checkDir(toDirName, expectedResultsDirName);
}
Also used : Search(com.yahoo.searchdefinition.Search) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) File(java.io.File) Test(org.junit.Test)

Example 54 with QueryProfileRegistry

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

the class ImplicitSearchFieldsTestCase method testRequireThatDerivedConfigurationWorks.

@Test
public void testRequireThatDerivedConfigurationWorks() throws IOException, ParseException {
    SearchBuilder sb = new SearchBuilder();
    sb.importFile("src/test/examples/nextgen/simple.sd");
    sb.build();
    assertNotNull(sb.getSearch());
    new DerivedConfiguration(sb.getSearch(), sb.getRankProfileRegistry(), new QueryProfileRegistry());
}
Also used : DerivedConfiguration(com.yahoo.searchdefinition.derived.DerivedConfiguration) SearchBuilder(com.yahoo.searchdefinition.SearchBuilder) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 55 with QueryProfileRegistry

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

the class RankingExpressionConstantsTestCase method testConstants.

@Test
public void testConstants() throws ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    QueryProfileRegistry queryProfileRegistry = new QueryProfileRegistry();
    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" + "        constants {\n" + "            p1: 7 \n" + "            p2: 0 \n" + "        }\n" + "        first-phase {\n" + "            expression: p2 * (1.3 + p1 )\n" + "        }\n" + "    }\n" + "    rank-profile child1 inherits parent {\n" + "        first-phase {\n" + "            expression: a + b + c \n" + "        }\n" + "        second-phase {\n" + "            expression: a + p1 + c \n" + "        }\n" + "        constants {\n" + "            a: 1.0 \n" + "            b: 2 \n" + "            c: 3.5 \n" + "        }\n" + "    }\n" + "    rank-profile child2 inherits parent {\n" + "        constants {\n" + "            p2: 2.0 \n" + "        }\n" + "        macro foo() {\n" + "            expression: p2*p1\n" + "        }\n" + "    }\n" + "\n" + "}\n");
    builder.build();
    Search s = builder.getSearch();
    RankProfile parent = rankProfileRegistry.getRankProfile(s, "parent").compile(queryProfileRegistry);
    assertEquals("0.0", parent.getFirstPhaseRanking().getRoot().toString());
    RankProfile child1 = rankProfileRegistry.getRankProfile(s, "child1").compile(queryProfileRegistry);
    assertEquals("6.5", child1.getFirstPhaseRanking().getRoot().toString());
    assertEquals("11.5", child1.getSecondPhaseRanking().getRoot().toString());
    RankProfile child2 = rankProfileRegistry.getRankProfile(s, "child2").compile(queryProfileRegistry);
    assertEquals("16.6", child2.getFirstPhaseRanking().getRoot().toString());
    assertEquals("foo: 14.0", child2.getMacros().get("foo").getRankingExpression().toString());
    List<Pair<String, String>> rankProperties = new RawRankProfile(child2, queryProfileRegistry, new AttributeFields(s)).configProperties();
    assertEquals("(rankingExpression(foo).rankingScript,14.0)", rankProperties.get(0).toString());
    assertEquals("(rankingExpression(firstphase).rankingScript,16.6)", rankProperties.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)

Aggregations

QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)68 Test (org.junit.Test)38 QueryProfile (com.yahoo.search.query.profile.QueryProfile)24 CompiledQueryProfileRegistry (com.yahoo.search.query.profile.compiled.CompiledQueryProfileRegistry)16 RawRankProfile (com.yahoo.searchdefinition.derived.RawRankProfile)16 QueryProfileType (com.yahoo.search.query.profile.types.QueryProfileType)14 Query (com.yahoo.search.Query)11 AttributeFields (com.yahoo.searchdefinition.derived.AttributeFields)11 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)11 Pair (com.yahoo.collections.Pair)8 QueryProfileXMLReader (com.yahoo.search.query.profile.config.QueryProfileXMLReader)8 Search (com.yahoo.searchdefinition.Search)8 FieldDescription (com.yahoo.search.query.profile.types.FieldDescription)7 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)6 SDField (com.yahoo.searchdefinition.document.SDField)5 ComponentId (com.yahoo.component.ComponentId)4 CompiledQueryProfile (com.yahoo.search.query.profile.compiled.CompiledQueryProfile)4 QueryProfileTypeRegistry (com.yahoo.search.query.profile.types.QueryProfileTypeRegistry)4