use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class TypedProfilesConfigurationTestCase method testIt.
/**
* Asserts that everything is read correctly from this configuration
*/
public void testIt() {
QueryProfileConfigurer configurer = new QueryProfileConfigurer("file:src/test/java/com/yahoo/search/query/profile/config/test/typed-profiles.cfg");
QueryProfileRegistry registry = configurer.getCurrentRegistry();
QueryProfileTypeRegistry types = registry.getTypeRegistry();
// Assert that each type was read correctly
QueryProfileType testType = types.getComponent("testtype");
assertEquals("testtype", testType.getId().getName());
assertFalse(testType.isStrict());
assertFalse(testType.getMatchAsPath());
assertEquals(7, testType.fields().size());
assertEquals("myString", testType.getField("myString").getName());
assertTrue(testType.getField("myString").isMandatory());
assertTrue(testType.getField("myString").isOverridable());
assertFalse(testType.getField("myInteger").isMandatory());
assertFalse(testType.getField("myInteger").isOverridable());
FieldDescription field = testType.getField("myUserQueryProfile");
assertEquals("reference to a query profile of type 'user'", field.getType().toInstanceDescription());
assertTrue(field.getAliases().contains("myqp"));
assertTrue(field.getAliases().contains("user-profile"));
QueryProfileType testTypeStrict = types.getComponent("testtypestrict");
assertTrue(testTypeStrict.isStrict());
assertTrue(testTypeStrict.getMatchAsPath());
assertEquals(7, testTypeStrict.fields().size());
assertEquals("reference to a query profile of type 'userstrict'", testTypeStrict.getField("myUserQueryProfile").getType().toInstanceDescription());
QueryProfileType user = types.getComponent("user");
assertFalse(user.isStrict());
assertFalse(user.getMatchAsPath());
assertEquals(2, user.fields().size());
assertEquals(String.class, user.getField("myUserString").getType().getValueClass());
QueryProfileType userStrict = types.getComponent("userstrict");
assertTrue(userStrict.isStrict());
assertFalse(userStrict.getMatchAsPath());
assertEquals(2, userStrict.fields().size());
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class RankProfileTestCase method verifyRankProfile.
private void verifyRankProfile(RankProfile rankProfile, AttributeFields attributeFields) {
assertEquals(0.78, rankProfile.getTermwiseLimit(), 0.000001);
assertEquals(8, rankProfile.getNumThreadsPerSearch());
assertEquals(70, rankProfile.getMinHitsPerThread());
assertEquals(1200, rankProfile.getNumSearchPartitions());
RawRankProfile rawRankProfile = new RawRankProfile(rankProfile, new QueryProfileRegistry(), attributeFields);
assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.termwise_limit").isPresent());
assertEquals("0.78", findProperty(rawRankProfile.configProperties(), "vespa.matching.termwise_limit").get());
assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.numthreadspersearch").isPresent());
assertEquals("8", findProperty(rawRankProfile.configProperties(), "vespa.matching.numthreadspersearch").get());
assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.minhitsperthread").isPresent());
assertEquals("70", findProperty(rawRankProfile.configProperties(), "vespa.matching.minhitsperthread").get());
assertTrue(findProperty(rawRankProfile.configProperties(), "vespa.matching.numsearchpartitions").isPresent());
assertEquals("1200", findProperty(rawRankProfile.configProperties(), "vespa.matching.numsearchpartitions").get());
}
use of com.yahoo.search.query.profile.QueryProfileRegistry 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());
}
use of com.yahoo.search.query.profile.QueryProfileRegistry 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());
}
use of com.yahoo.search.query.profile.QueryProfileRegistry in project vespa by vespa-engine.
the class RankingExpressionInliningTestCase method testMacroInliningPreserveArithemticOrdering.
@Test
public void testMacroInliningPreserveArithemticOrdering() throws ParseException {
RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
SearchBuilder builder = new SearchBuilder(rankProfileRegistry);
builder.importString("search test {\n" + " document test { \n" + " field a type double { \n" + " indexing: attribute \n" + " }\n" + " field b type double { \n" + " indexing: attribute \n" + " }\n" + " }\n" + " \n" + " rank-profile parent {\n" + " constants {\n" + " p1: 7 \n" + " p2: 0 \n" + " }\n" + " first-phase {\n" + " expression: p1 * add\n" + " }\n" + " macro inline add() {\n" + " expression: 3 + attribute(a) + attribute(b) * mul3\n" + " }\n" + " macro inline mul3() {\n" + " expression: attribute(a) * 3 + singleif\n" + " }\n" + " macro inline singleif() {\n" + " expression: if (p1 < attribute(a), 1, 2) == 0\n" + " }\n" + " }\n" + " rank-profile child inherits parent {\n" + " macro inline add() {\n" + " expression: 9 + attribute(a)\n" + " }\n" + " }\n" + "\n" + "}\n");
builder.build();
Search s = builder.getSearch();
RankProfile parent = rankProfileRegistry.getRankProfile(s, "parent").compile(new QueryProfileRegistry());
assertEquals("7.0 * (3 + attribute(a) + attribute(b) * (attribute(a) * 3 + if (7.0 < attribute(a), 1, 2) == 0))", parent.getFirstPhaseRanking().getRoot().toString());
RankProfile child = rankProfileRegistry.getRankProfile(s, "child").compile(new QueryProfileRegistry());
assertEquals("7.0 * (9 + attribute(a))", child.getFirstPhaseRanking().getRoot().toString());
}
Aggregations