Search in sources :

Example 1 with BaseDeployLogger

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

the class SearchBuilder method createFromDirectory.

public static SearchBuilder createFromDirectory(String dir, RankProfileRegistry rankProfileRegistry, QueryProfileRegistry queryProfileRegistry) throws IOException, ParseException {
    SearchBuilder builder = new SearchBuilder(MockApplicationPackage.fromSearchDefinitionDirectory(dir), rankProfileRegistry, queryProfileRegistry);
    for (Iterator<Path> i = Files.list(new File(dir).toPath()).filter(p -> p.getFileName().toString().endsWith(".sd")).iterator(); i.hasNext(); ) {
        builder.importFile(i.next());
    }
    builder.build(true, new BaseDeployLogger());
    return builder;
}
Also used : Path(java.nio.file.Path) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) DocumentModel(com.yahoo.vespa.documentmodel.DocumentModel) SDParser(com.yahoo.searchdefinition.parser.SDParser) IOUtils(com.yahoo.io.IOUtils) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) DeployLogger(com.yahoo.config.application.api.DeployLogger) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) ArrayList(java.util.ArrayList) SearchOrderer(com.yahoo.searchdefinition.derived.SearchOrderer) Processing(com.yahoo.searchdefinition.processing.Processing) TokenMgrError(com.yahoo.searchdefinition.parser.TokenMgrError) LinkedList(java.util.LinkedList) Path(java.nio.file.Path) ApplicationPackage(com.yahoo.config.application.api.ApplicationPackage) Exceptions(com.yahoo.yolean.Exceptions) SimpleCharStream(com.yahoo.searchdefinition.parser.SimpleCharStream) Iterator(java.util.Iterator) Files(java.nio.file.Files) IOException(java.io.IOException) MockApplicationPackage(com.yahoo.config.model.test.MockApplicationPackage) File(java.io.File) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) List(java.util.List) NamedReader(com.yahoo.io.reader.NamedReader) ParseException(com.yahoo.searchdefinition.parser.ParseException) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) File(java.io.File)

Example 2 with BaseDeployLogger

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

the class SummaryMapTestCase method testPositionDeriving.

@Test
public void testPositionDeriving() throws IOException, ParseException {
    Search search = new Search("store", null);
    SDDocumentType document = new SDDocumentType("store");
    search.addDocument(document);
    String fieldName = "location";
    SDField field = document.addField(fieldName, PositionDataType.INSTANCE);
    field.parseIndexingScript("{ attribute | summary }");
    Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
    SummaryMap summaryMap = new SummaryMap(search, new Summaries(search, new BaseDeployLogger()));
    Iterator transforms = summaryMap.resultTransformIterator();
    FieldResultTransform transform = (FieldResultTransform) transforms.next();
    assertEquals(fieldName, transform.getFieldName());
    assertEquals(SummaryTransform.GEOPOS, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals(PositionDataType.getPositionSummaryFieldName(fieldName), transform.getFieldName());
    assertEquals(SummaryTransform.POSITIONS, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals(PositionDataType.getDistanceSummaryFieldName(fieldName), transform.getFieldName());
    assertEquals(SummaryTransform.DISTANCE, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals("rankfeatures", transform.getFieldName());
    assertEquals(SummaryTransform.RANKFEATURES, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals("summaryfeatures", transform.getFieldName());
    assertEquals(SummaryTransform.SUMMARYFEATURES, transform.getTransform());
    transform = (FieldResultTransform) transforms.next();
    assertEquals("location_zcurve", transform.getFieldName());
    assertEquals(SummaryTransform.ATTRIBUTE, transform.getTransform());
    assertTrue(!transforms.hasNext());
    SummarymapConfig.Builder scb = new SummarymapConfig.Builder();
    summaryMap.getConfig(scb);
    SummarymapConfig c = new SummarymapConfig(scb);
    assertEquals(-1, c.defaultoutputclass());
    assertEquals(c.override().size(), 6);
    assertEquals(c.override(0).field(), fieldName);
    assertEquals(c.override(0).command(), "geopos");
    assertEquals(c.override(0).arguments(), PositionDataType.getZCurveFieldName(fieldName));
    assertEquals(c.override(1).field(), PositionDataType.getPositionSummaryFieldName(fieldName));
    assertEquals(c.override(1).command(), "positions");
    assertEquals(c.override(1).arguments(), PositionDataType.getZCurveFieldName(fieldName));
    assertEquals(c.override(2).field(), PositionDataType.getDistanceSummaryFieldName(fieldName));
    assertEquals(c.override(2).command(), "absdist");
    assertEquals(c.override(2).arguments(), PositionDataType.getZCurveFieldName(fieldName));
    assertEquals(c.override(3).field(), "rankfeatures");
    assertEquals(c.override(3).command(), "rankfeatures");
    assertEquals(c.override(3).arguments(), "");
    assertEquals(c.override(4).field(), "summaryfeatures");
    assertEquals(c.override(4).command(), "summaryfeatures");
    assertEquals(c.override(4).arguments(), "");
    assertEquals(c.override(5).field(), "location_zcurve");
    assertEquals(c.override(5).command(), "attribute");
    assertEquals(c.override(5).arguments(), "location_zcurve");
}
Also used : SummarymapConfig(com.yahoo.vespa.config.search.SummarymapConfig) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 3 with BaseDeployLogger

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

the class BoldingTestCase method testBoldingNonString.

@Test
public void testBoldingNonString() throws IOException, ParseException {
    try {
        Search search = UnprocessingSearchBuilder.buildUnprocessedFromFile("src/test/processing/boldnonstring.sd");
        new Bolding(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles()).process(true);
        fail();
    } catch (IllegalArgumentException e) {
        assertTrue(e.getMessage().contains("'bolding: on' for non-text field"));
    }
}
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 4 with BaseDeployLogger

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

the class IdTestCase method testExplicitUpperCaseIdField.

@Test
@SuppressWarnings({ "deprecation" })
public void testExplicitUpperCaseIdField() {
    Search search = new Search("test", null);
    SDDocumentType document = new SDDocumentType("test");
    search.addDocument(document);
    SDField uri = new SDField("URI", DataType.URI);
    uri.parseIndexingScript("{ summary | index }");
    document.addField(uri);
    Processing.process(search, new BaseDeployLogger(), new RankProfileRegistry(), new QueryProfiles(), true);
    assertNull(document.getField("uri"));
    assertNull(document.getField("Uri"));
    assertNotNull(document.getField("URI"));
}
Also used : RankProfileRegistry(com.yahoo.searchdefinition.RankProfileRegistry) SDField(com.yahoo.searchdefinition.document.SDField) SDDocumentType(com.yahoo.searchdefinition.document.SDDocumentType) 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 5 with BaseDeployLogger

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

the class LiteralBoostTestCase method testLiteralBoost.

/**
 * Tests adding of literal boost constructs
 */
@Test
public void testLiteralBoost() {
    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 }");
    field1.setLiteralBoost(20);
    RankProfile other = new RankProfile("other", search, rankProfileRegistry);
    rankProfileRegistry.addRankProfile(other);
    other.addRankSetting(new RankProfile.RankSetting("a", RankProfile.RankSetting.Type.LITERALBOOST, 333));
    Processing.process(search, new BaseDeployLogger(), rankProfileRegistry, new QueryProfiles(), true);
    DerivedConfiguration derived = new DerivedConfiguration(search, rankProfileRegistry, new QueryProfileRegistry());
    // Check attribute fields
    // TODO: assert content
    derived.getAttributeFields();
    // 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) BaseDeployLogger(com.yahoo.config.model.application.provider.BaseDeployLogger) Search(com.yahoo.searchdefinition.Search) QueryProfiles(com.yahoo.vespa.model.container.search.QueryProfiles) QueryProfileRegistry(com.yahoo.search.query.profile.QueryProfileRegistry) RankProfile(com.yahoo.searchdefinition.RankProfile) 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