Search in sources :

Example 31 with BaseDeployLogger

use of com.yahoo.config.model.application.provider.BaseDeployLogger in project vespa by vespa-engine.

the class AttributePropertiesTestCase method testValidAttributeProperties.

@Test
public void testValidAttributeProperties() throws IOException, ParseException {
    Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/examples/attributeproperties2.sd");
    new AttributeProperties(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Test(org.junit.Test)

Example 32 with BaseDeployLogger

use of com.yahoo.config.model.application.provider.BaseDeployLogger in project vespa by vespa-engine.

the class SearchImporterTestCase method testSimpleImporting.

@Test
public void testSimpleImporting() throws IOException, ParseException {
    RankProfileRegistry rankProfileRegistry = new RankProfileRegistry();
    SearchBuilder sb = new UnprocessingSearchBuilder(rankProfileRegistry, new QueryProfileRegistry());
    sb.importFile("src/test/examples/simple.sd");
    sb.build();
    Search search = sb.getSearch();
    assertEquals("simple", search.getName());
    assertTrue(search.hasDocument());
    SDDocumentType document = search.getDocument();
    assertEquals("simple", document.getName());
    assertEquals(12, document.getFieldCount());
    SDField field;
    Attribute attribute;
    new MakeAliases(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles()).process(true);
    // First field
    field = (SDField) document.getField("title");
    assertEquals(DataType.STRING, field.getDataType());
    assertEquals("{ summary | index; }", field.getIndexingScript().toString());
    assertTrue(!search.getIndex("default").isPrefix());
    assertTrue(search.getIndex("title").isPrefix());
    Iterator<String> titleAliases = search.getIndex("title").aliasIterator();
    assertEquals("aliaz", titleAliases.next());
    assertEquals("analias.totitle", titleAliases.next());
    assertEquals("analias.todefault", search.getIndex("default").aliasIterator().next());
    assertEquals(RankType.IDENTITY, field.getRankType());
    assertTrue(field.getAttributes().size() == 0);
    assertNull(field.getStemming());
    assertTrue(field.getNormalizing().doRemoveAccents());
    assertTrue(field.isHeader());
    // Second field
    field = (SDField) document.getField("description");
    assertEquals(RankType.ABOUT, field.getRankType());
    assertEquals(SummaryTransform.NONE, field.getSummaryField("description").getTransform());
    assertEquals(SummaryTransform.DYNAMICTEASER, field.getSummaryField("dyndesc").getTransform());
    assertNull(field.getStemming());
    assertTrue(field.getNormalizing().doRemoveAccents());
    assertEquals("hallo", search.getIndex("description").aliasIterator().next());
    // Third field
    field = (SDField) document.getField("chatter");
    assertEquals(RankType.ABOUT, field.getRankType());
    assertNull(field.getStemming());
    assertTrue(field.getNormalizing().doRemoveAccents());
    // Fourth field
    field = (SDField) document.getField("category");
    assertEquals(0, field.getAttributes().size());
    assertEquals(Stemming.NONE, field.getStemming());
    assertTrue(!field.getNormalizing().doRemoveAccents());
    // Fifth field
    field = (SDField) document.getField("popularity");
    assertEquals("{ attribute; }", field.getIndexingScript().toString());
    // Sixth field
    field = (SDField) document.getField("measurement");
    assertEquals(DataType.INT, field.getDataType());
    assertEquals(RankType.EMPTY, field.getRankType());
    assertEquals(1, field.getAttributes().size());
    // Seventh field
    field = search.getConcreteField("categories");
    assertEquals("{ input categories_src | lowercase | normalize | index; }", field.getIndexingScript().toString());
    assertTrue(!field.isHeader());
    // Eight field
    field = search.getConcreteField("categoriesagain");
    assertEquals("{ input categoriesagain_src | lowercase | normalize | index; }", field.getIndexingScript().toString());
    assertTrue(field.isHeader());
    // Ninth field
    field = search.getConcreteField("exactemento");
    assertEquals("{ input exactemento_src | lowercase | index | summary; }", field.getIndexingScript().toString());
    // Tenth field
    field = search.getConcreteField("category_arr");
    assertEquals(1, field.getAttributes().size());
    attribute = field.getAttributes().get("category_arr");
    assertNotNull(attribute);
    assertEquals("category_arr", attribute.getName());
    assertEquals(Attribute.Type.STRING, attribute.getType());
    assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
    assertTrue(field.isHeader());
    // Eleventh field
    field = search.getConcreteField("measurement_arr");
    assertEquals(1, field.getAttributes().size());
    attribute = field.getAttributes().get("measurement_arr");
    assertEquals("measurement_arr", attribute.getName());
    assertEquals(Attribute.Type.INTEGER, attribute.getType());
    assertEquals(Attribute.CollectionType.ARRAY, attribute.getCollectionType());
    // Rank Profiles
    RankProfile profile = rankProfileRegistry.getRankProfile(search, "default");
    assertNotNull(profile);
    assertNull(profile.getInheritedName());
    assertEquals(null, profile.getDeclaredRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE));
    assertEquals(RankType.EMPTY, profile.getRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE).getValue());
    profile = rankProfileRegistry.getRankProfile(search, "experimental");
    assertNotNull(profile);
    assertEquals("default", profile.getInheritedName());
    assertEquals(RankType.IDENTITY, profile.getDeclaredRankSetting("measurement", RankProfile.RankSetting.Type.RANKTYPE).getValue());
    profile = rankProfileRegistry.getRankProfile(search, "other");
    assertNotNull(profile);
    assertEquals("experimental", profile.getInheritedName());
    // The extra-document field
    SDField exact = search.getConcreteField("exact");
    assertNotNull("Extra field was parsed", exact);
    assertEquals("exact", exact.getName());
    assertEquals(Stemming.NONE, exact.getStemming());
    assertTrue(!exact.getNormalizing().doRemoveAccents());
    assertEquals("{ input title . \" \" . input category | summary | index; }", exact.getIndexingScript().toString());
    assertEquals(RankType.IDENTITY, exact.getRankType());
}
Also used : BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) MakeAliases(com.yahoo.searchdefinition.processing.MakeAliases) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) Test(org.junit.Test)

Example 33 with BaseDeployLogger

use of com.yahoo.config.model.application.provider.BaseDeployLogger in project vespa by vespa-engine.

the class FileSenderTest method require_that_arrays_are_modified.

@Test
public void require_that_arrays_are_modified() {
    def.arrayDef("fileArray").setTypeSpec(new ConfigDefinition.TypeSpec("fileArray", "file", null, null, null, null));
    def.arrayDef("pathArray").setTypeSpec(new ConfigDefinition.TypeSpec("pathArray", "path", null, null, null, null));
    def.arrayDef("stringArray").setTypeSpec(new ConfigDefinition.TypeSpec("stringArray", "string", null, null, null, null));
    builder.getArray("fileArray").append("foo.txt");
    builder.getArray("fileArray").append("bar.txt");
    builder.getArray("pathArray").append("path.txt");
    builder.getArray("stringArray").append("foo.txt");
    service.pathToRef.put("foo.txt", new FileNode("foohash").value());
    service.pathToRef.put("bar.txt", new FileNode("barhash").value());
    service.pathToRef.put("path.txt", new FileNode("pathhash").value());
    FileSender.sendUserConfiguredFiles(producer, serviceList, new BaseDeployLogger());
    assertThat(builder.getArray("fileArray").get(0).getValue(), is("foohash"));
    assertThat(builder.getArray("fileArray").get(1).getValue(), is("barhash"));
    assertThat(builder.getArray("pathArray").get(0).getValue(), is("pathhash"));
    assertThat(builder.getArray("stringArray").get(0).getValue(), is("foo.txt"));
}
Also used : BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) FileNode(com.yahoo.config.FileNode) Test(org.junit.Test)

Example 34 with BaseDeployLogger

use of com.yahoo.config.model.application.provider.BaseDeployLogger in project vespa by vespa-engine.

the class FileSenderTest method require_that_simple_path_fields_are_modified.

@Test
public void require_that_simple_path_fields_are_modified() {
    def.addPathDef("fileVal");
    def.addStringDef("stringVal");
    builder.setField("fileVal", "foo.txt");
    builder.setField("stringVal", "foo.txt");
    service.pathToRef.put("foo.txt", new FileNode("fooshash").value());
    FileSender.sendUserConfiguredFiles(producer, serviceList, new BaseDeployLogger());
    assertThat(builder.getObject("fileVal").getValue(), is("fooshash"));
    assertThat(builder.getObject("stringVal").getValue(), is("foo.txt"));
}
Also used : BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) FileNode(com.yahoo.config.FileNode) Test(org.junit.Test)

Example 35 with BaseDeployLogger

use of com.yahoo.config.model.application.provider.BaseDeployLogger in project vespa by vespa-engine.

the class FileSenderTest method require_that_fields_in_inner_arrays_are_modified.

@Test
public void require_that_fields_in_inner_arrays_are_modified() {
    def.innerArrayDef("inner").addFileDef("fileVal");
    def.innerArrayDef("inner").addStringDef("stringVal");
    ConfigPayloadBuilder inner = builder.getArray("inner").append();
    inner.setField("fileVal", "bar.txt");
    inner.setField("stringVal", "bar.txt");
    service.pathToRef.put("bar.txt", new FileNode("barhash").value());
    FileSender.sendUserConfiguredFiles(producer, serviceList, new BaseDeployLogger());
    assertThat(builder.getArray("inner").get(0).getObject("fileVal").getValue(), is("barhash"));
    assertThat(builder.getArray("inner").get(0).getObject("stringVal").getValue(), is("bar.txt"));
}
Also used : BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) FileNode(com.yahoo.config.FileNode) Test(org.junit.Test)

Aggregations

BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)39 Test (org.junit.Test)30 Search (com.yahoo.searchdefinition.Search)12 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)12 RankProfileRegistry (com.yahoo.searchdefinition.RankProfileRegistry)10 FileNode (com.yahoo.config.FileNode)8 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)7 QueryProfileRegistry (com.yahoo.search.query.profile.QueryProfileRegistry)6 SDField (com.yahoo.searchdefinition.document.SDField)6 UserConfigRepo (com.yahoo.config.model.producer.UserConfigRepo)4 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)4 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)3 File (java.io.File)3 Iterator (java.util.Iterator)3 Element (org.w3c.dom.Element)3 Version (com.yahoo.component.Version)2 ApplicationPackage (com.yahoo.config.application.api.ApplicationPackage)2 DeployLogger (com.yahoo.config.application.api.DeployLogger)2 MockApplicationPackage (com.yahoo.config.model.test.MockApplicationPackage)2 RankProfile (com.yahoo.searchdefinition.RankProfile)2