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