Search in sources :

Example 1 with SummaryTransform

use of com.yahoo.vespa.documentmodel.SummaryTransform in project vespa by vespa-engine.

the class AddAttributeTransformToSummaryOfImportedFieldsTest method attribute_summary_transform_applied_to_summary_field_of_imported_field.

@Test
public void attribute_summary_transform_applied_to_summary_field_of_imported_field() {
    Search search = createSearchWithDocument(DOCUMENT_NAME);
    search.setImportedFields(createSingleImportedField(IMPORTED_FIELD_NAME));
    search.addSummary(createDocumentSummary(IMPORTED_FIELD_NAME));
    AddAttributeTransformToSummaryOfImportedFields processor = new AddAttributeTransformToSummaryOfImportedFields(search, null, null, null);
    processor.process(true);
    SummaryField summaryField = search.getSummaries().get(SUMMARY_NAME).getSummaryField(IMPORTED_FIELD_NAME);
    SummaryTransform actualTransform = summaryField.getTransform();
    assertEquals(SummaryTransform.ATTRIBUTE, actualTransform);
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) Search(com.yahoo.searchdefinition.Search) SummaryTransform(com.yahoo.vespa.documentmodel.SummaryTransform) Test(org.junit.Test)

Example 2 with SummaryTransform

use of com.yahoo.vespa.documentmodel.SummaryTransform in project vespa by vespa-engine.

the class IndexingScriptChangeMessageBuilder method checkSummaryTransform.

private void checkSummaryTransform(ChangeMessageBuilder builder) {
    for (SummaryField nextSummaryField : nextField.getSummaryFields()) {
        String fieldName = nextSummaryField.getName();
        SummaryField currentSummaryField = currentField.getSummaryField(fieldName);
        if (currentSummaryField != null) {
            SummaryTransform currentTransform = currentSummaryField.getTransform();
            SummaryTransform nextTransform = nextSummaryField.getTransform();
            if (!currentSummaryField.getTransform().equals(nextSummaryField.getTransform())) {
                builder.addChange("summary field '" + fieldName + "' transform", currentTransform.getName(), nextTransform.getName());
            }
        }
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SummaryTransform(com.yahoo.vespa.documentmodel.SummaryTransform)

Example 3 with SummaryTransform

use of com.yahoo.vespa.documentmodel.SummaryTransform in project vespa by vespa-engine.

the class IndexingOutputs method fillSummaryToFromSummaryField.

private void fillSummaryToFromSummaryField(Search search, SDField field, SummaryField summaryField, Set<String> dynamicSummary, Set<String> staticSummary) {
    SummaryTransform summaryTransform = summaryField.getTransform();
    String summaryName = summaryField.getName();
    if (summaryTransform.isDynamic() && summaryField.getSourceCount() > 2) {
        // summary rewriter in the search core.
        return;
    }
    if (summaryTransform.isDynamic()) {
        DataType fieldType = field.getDataType();
        if (fieldType != DataType.URI && fieldType != DataType.STRING) {
            warn(search, field, "Dynamic summaries are only supported for fields of type " + "string, ignoring summary field '" + summaryField.getName() + "' for sd field '" + field.getName() + "' of type " + fieldType.getName() + ".");
            return;
        }
        dynamicSummary.add(summaryName);
    } else if (summaryTransform != SummaryTransform.ATTRIBUTE) {
        staticSummary.add(summaryName);
    }
}
Also used : DataType(com.yahoo.document.DataType) SummaryTransform(com.yahoo.vespa.documentmodel.SummaryTransform)

Aggregations

SummaryTransform (com.yahoo.vespa.documentmodel.SummaryTransform)3 SummaryField (com.yahoo.vespa.documentmodel.SummaryField)2 DataType (com.yahoo.document.DataType)1 Search (com.yahoo.searchdefinition.Search)1 Test (org.junit.Test)1