Search in sources :

Example 36 with Search

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"));
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) Index(com.yahoo.searchdefinition.Index) Test(org.junit.Test)

Example 37 with Search

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);
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 38 with 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"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) Test(org.junit.Test)

Example 39 with Search

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;
}
Also used : SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) DocumentReferences(com.yahoo.searchdefinition.DocumentReferences)

Example 40 with 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;
}
Also used : HashMap(java.util.HashMap) Search(com.yahoo.searchdefinition.Search)

Aggregations

Search (com.yahoo.searchdefinition.Search)62 Test (org.junit.Test)47 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)21 SDField (com.yahoo.searchdefinition.document.SDField)15 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)13 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)12 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)8 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)8 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)6 File (java.io.File)5 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)4 RankProfile (com.yahoo.searchdefinition.RankProfile)3 Field (com.yahoo.document.Field)2 StructDataType (com.yahoo.document.StructDataType)2 WeightedSetDataType (com.yahoo.document.WeightedSetDataType)2 DocumentReference (com.yahoo.searchdefinition.DocumentReference)2 Index (com.yahoo.searchdefinition.Index)2 UnprocessingSearchBuilder (com.yahoo.searchdefinition.UnprocessingSearchBuilder)2 Attribute (com.yahoo.searchdefinition.document.Attribute)2 ImportedField (com.yahoo.searchdefinition.document.ImportedField)2