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;
}
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");
}
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"));
}
}
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"));
}
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"));
}
Aggregations