use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class InheritanceTestCase method testIndexSettingInheritance.
@Test
public void testIndexSettingInheritance() {
SDDocumentType parent = new SDDocumentType("parent");
Search parentSearch = new Search("parent", null);
parentSearch.addDocument(parent);
SDField prefixed = parent.addField("prefixed", DataType.STRING);
prefixed.parseIndexingScript("{ index }");
prefixed.addIndex(new Index("prefixed", true));
SDDocumentType child = new SDDocumentType("child");
child.inherit(parent);
Search childSearch = new Search("child", null);
childSearch.addDocument(child);
prefixed = (SDField) child.getField("prefixed");
assertNotNull(prefixed);
assertEquals(new Index("prefixed", true), childSearch.getIndex("prefixed"));
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class LiteralBoostTestCase method testTwoLiteralBoostFields.
/**
* Tests literal boosts in two fields going to the same index
*/
@Test
public void testTwoLiteralBoostFields() {
Search search = new Search("msb", null);
RankProfileRegistry rankProfileRegistry = RankProfileRegistry.createRankProfileRegistryWithBuiltinRankProfiles(search);
SDDocumentType document = new SDDocumentType("msb");
search.addDocument(document);
SDField field1 = document.addField("title", DataType.STRING);
field1.parseIndexingScript("{ summary | index }");
field1.setLiteralBoost(20);
SDField field2 = document.addField("body", DataType.STRING);
field2.parseIndexingScript("{ summary | index }");
field2.setLiteralBoost(20);
search = SearchBuilder.buildFromRawSearch(search, rankProfileRegistry, new QueryProfileRegistry());
new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
assertIndexing(Arrays.asList("clear_state | guard { input title | tokenize normalize stem:\"SHORTEST\" | summary title | index title; }", "clear_state | guard { input body | tokenize normalize stem:\"SHORTEST\" | summary body | index body; }", "clear_state | guard { input title | tokenize | index title_literal; }", "clear_state | guard { input body | tokenize | index body_literal; }"), search);
}
use of com.yahoo.searchdefinition.Search 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.Search in project vespa by vespa-engine.
the class SearchOrdererTestCase method createSearchDefinition.
private static Search createSearchDefinition(String name, Map<String, Search> searchDefinitions) {
Search search = new Search(name, null);
SDDocumentType document = new SDDocumentType(name);
document.setDocumentReferences(new DocumentReferences(emptyMap()));
search.addDocument(document);
searchDefinitions.put(search.getName(), search);
return search;
}
use of com.yahoo.searchdefinition.Search in project vespa by vespa-engine.
the class SearchOrdererTestCase method createSearchDefinitions.
private static Map<String, Search> createSearchDefinitions() {
Map<String, Search> searchDefinitions = new HashMap<>();
Search grandParent = createSearchDefinition("grandParent", searchDefinitions);
Search mother = createSearchDefinition("mother", searchDefinitions);
inherit(mother, grandParent);
Search father = createSearchDefinition("father", searchDefinitions);
inherit(father, grandParent);
createDocumentReference(father, mother, "wife_ref");
Search daugther = createSearchDefinition("daughter", searchDefinitions);
inherit(daugther, father);
inherit(daugther, mother);
Search son = createSearchDefinition("son", searchDefinitions);
inherit(son, father);
inherit(son, mother);
Search product = createSearchDefinition("product", searchDefinitions);
Search pc = createSearchDefinition("pc", searchDefinitions);
inherit(pc, product);
Search pcAccessory = createSearchDefinition("accessory-pc", searchDefinitions);
inherit(pcAccessory, product);
createDocumentReference(pcAccessory, pc, "pc_ref");
createSearchDefinition("alone", searchDefinitions);
return searchDefinitions;
}
Aggregations