Search in sources :

Example 36 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class SDDocumentTypeOrdererTestCase method testOrder.

@Test
public void testOrder() {
    List<SDDocumentType> types = new ArrayList<>();
    SDDocumentType a = new SDDocumentType("a");
    SDDocumentType b = new SDDocumentType("b");
    SDDocumentType c = new SDDocumentType("c");
    SDDocumentType d = new SDDocumentType("d");
    SDDocumentType e = new SDDocumentType("e");
    SDDocumentType f = new SDDocumentType("f");
    SDDocumentType g = new SDDocumentType("g");
    b.inherit(new TemporarySDDocumentType(new DataTypeName("a")));
    c.inherit(new TemporarySDDocumentType(new DataTypeName("b")));
    d.inherit(new TemporarySDDocumentType(new DataTypeName("e")));
    g.inherit(new TemporarySDDocumentType(new DataTypeName("e")));
    g.inherit(new TemporarySDDocumentType(new DataTypeName("c")));
    SDField aFieldTypeB = new TemporarySDField("atypeb", DataType.STRING);
    a.addField(aFieldTypeB);
    SDField bFieldTypeC = new TemporarySDField("btypec", DataType.STRING);
    b.addField(bFieldTypeC);
    SDField cFieldTypeG = new TemporarySDField("ctypeg", DataType.STRING);
    c.addField(cFieldTypeG);
    SDField gFieldTypeF = new TemporarySDField("gtypef", DataType.STRING);
    g.addField(gFieldTypeF);
    SDField fFieldTypeC = new TemporarySDField("ftypec", DataType.STRING);
    f.addField(fFieldTypeC);
    SDField dFieldTypeE = new TemporarySDField("dtypee", DataType.STRING);
    d.addField(dFieldTypeE);
    types.add(a);
    types.add(b);
    types.add(c);
    types.add(d);
    types.add(e);
    types.add(f);
    types.add(g);
    SDDocumentTypeOrderer app = new SDDocumentTypeOrderer(types, new BaseDeployLogger());
    app.process();
    assertEquals(7, app.processingOrder.size());
    assertEquals(a, app.processingOrder.get(0));
    assertEquals(b, app.processingOrder.get(1));
    assertEquals(c, app.processingOrder.get(2));
    assertEquals(e, app.processingOrder.get(3));
    assertEquals(d, app.processingOrder.get(4));
    assertEquals(f, app.processingOrder.get(5));
    assertEquals(g, app.processingOrder.get(6));
}
Also used : TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) TemporarySDDocumentType(com.yahoo.searchdefinition.document.TemporarySDDocumentType) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ArrayList(java.util.ArrayList) DataTypeName(com.yahoo.document.DataTypeName) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) Test(org.junit.Test)

Example 37 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType in project vespa by vespa-engine.

the class VsmFieldsTestCase method reference_type_field_is_unsearchable.

@Test
public void reference_type_field_is_unsearchable() {
    Search search = new Search("test", MockApplicationPackage.createEmpty());
    search.addDocument(new SDDocumentType("test"));
    SDField refField = new TemporarySDField("ref_field", ReferenceDataType.createWithInferredId(TemporaryStructuredDataType.create("parent_type")));
    refField.parseIndexingScript("{ summary }");
    search.getDocument().addField(refField);
    VsmFields vsmFields = new VsmFields(search);
    VsmfieldsConfig.Builder cfgBuilder = new VsmfieldsConfig.Builder();
    vsmFields.getConfig(cfgBuilder);
    VsmfieldsConfig cfg = new VsmfieldsConfig(cfgBuilder);
    assertEquals(1, cfg.fieldspec().size());
    VsmfieldsConfig.Fieldspec fieldSpec = cfg.fieldspec().get(0);
    assertEquals("ref_field", fieldSpec.name());
    assertEquals(VsmfieldsConfig.Fieldspec.Searchmethod.NONE, fieldSpec.searchmethod());
}
Also used : TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) Search(com.yahoo.searchdefinition.Search) TemporarySDField(com.yahoo.searchdefinition.document.TemporarySDField) VsmfieldsConfig(com.yahoo.vespa.config.search.vsm.VsmfieldsConfig) Test(org.junit.Test)

Example 38 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType 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 39 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType 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 40 with SDDocumentType

use of com.yahoo.searchdefinition.document.SDDocumentType 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)

Aggregations

SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)48 Test (org.junit.Test)28 SDField (com.yahoo.searchdefinition.document.SDField)23 Search (com.yahoo.searchdefinition.Search)21 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)7 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)6 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)6 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)5 TemporarySDField (com.yahoo.searchdefinition.document.TemporarySDField)4 ArrayList (java.util.ArrayList)4 DataTypeName (com.yahoo.document.DataTypeName)3 TemporarySDDocumentType (com.yahoo.searchdefinition.document.TemporarySDDocumentType)3 HashMap (java.util.HashMap)3 NewDocumentType (com.yahoo.documentmodel.NewDocumentType)2 DocumentReferences (com.yahoo.searchdefinition.DocumentReferences)2 RankProfile (com.yahoo.searchdefinition.RankProfile)2 SearchBuilder (com.yahoo.searchdefinition.SearchBuilder)2 Iterator (java.util.Iterator)2 LinkedList (java.util.LinkedList)2 DataType (com.yahoo.document.DataType)1