Search in sources :

Example 1 with SummarymapConfig

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");
}
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 2 with SummarymapConfig

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);
    }
}
Also used : SummarymapConfig(com.yahoo.vespa.config.search.SummarymapConfig) SummaryConfig(com.yahoo.vespa.config.search.SummaryConfig) DocumentdbInfoConfig(com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)

Aggregations

SummarymapConfig (com.yahoo.vespa.config.search.SummarymapConfig)2 BaseDeployLogger (com.yahoo.config.model.application.provider.BaseDeployLogger)1 DocumentdbInfoConfig (com.yahoo.prelude.fastsearch.DocumentdbInfoConfig)1 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)1 SDField (com.yahoo.searchdefinition.document.SDField)1 SummaryConfig (com.yahoo.vespa.config.search.SummaryConfig)1 QueryProfiles (com.yahoo.vespa.model.container.search.QueryProfiles)1 Iterator (java.util.Iterator)1 Test (org.junit.Test)1