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));
}
}
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());
}
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);
}
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());
}
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());
}
Aggregations