use of com.yahoo.vespa.config.search.SummarymapConfig 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.vespa.config.search.SummarymapConfig in project vespa by vespa-engine.
the class SearchCluster method convertSummaryConfig.
/**
* Converts summary and summary map config to the appropriate information in documentdb
*
* @param summaryConfigProducer the summary config
* @param summarymapConfigProducer the summary map config, or null if none is available
* @param docDb the target document dm config
*/
protected void convertSummaryConfig(SummaryConfig.Producer summaryConfigProducer, SummarymapConfig.Producer summarymapConfigProducer, DocumentdbInfoConfig.Documentdb.Builder docDb) {
SummaryConfig.Builder summaryConfigBuilder = new SummaryConfig.Builder();
summaryConfigProducer.getConfig(summaryConfigBuilder);
SummaryConfig summaryConfig = new SummaryConfig(summaryConfigBuilder);
SummarymapConfig summarymapConfig = null;
if (summarymapConfigProducer != null) {
SummarymapConfig.Builder summarymapConfigBuilder = new SummarymapConfig.Builder();
summarymapConfigProducer.getConfig(summarymapConfigBuilder);
summarymapConfig = new SummarymapConfig(summarymapConfigBuilder);
}
for (SummaryConfig.Classes sclass : summaryConfig.classes()) {
DocumentdbInfoConfig.Documentdb.Summaryclass.Builder sumClassBuilder = new DocumentdbInfoConfig.Documentdb.Summaryclass.Builder();
sumClassBuilder.id(sclass.id()).name(sclass.name());
for (SummaryConfig.Classes.Fields field : sclass.fields()) {
DocumentdbInfoConfig.Documentdb.Summaryclass.Fields.Builder fieldsBuilder = new DocumentdbInfoConfig.Documentdb.Summaryclass.Fields.Builder();
fieldsBuilder.name(field.name()).type(field.type()).dynamic(isDynamic(field.name(), summarymapConfig));
sumClassBuilder.fields(fieldsBuilder);
}
docDb.summaryclass(sumClassBuilder);
}
}
Aggregations