Search in sources :

Example 11 with SummaryField

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

the class AddExtraFieldsToDocument method addSummaryField.

private void addSummaryField(Search search, SDDocumentType document, SummaryField field, boolean validate) {
    Field docField = document.getField(field.getName());
    if (docField == null) {
        ImmutableSDField existingField = search.getField(field.getName());
        if (existingField == null) {
            SDField newField = new SDField(document, field.getName(), field.getDataType(), field.isHeader(), true);
            newField.setIsExtraField(true);
            document.addField(newField);
        } else if (!existingField.isImportedField()) {
            document.addField(existingField.asField());
        }
    } else if (!docField.getDataType().equals(field.getDataType())) {
        if (validate)
            throw newProcessException(search, field, "Summary field has conflicting type.");
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) SDField(com.yahoo.searchdefinition.document.SDField) Field(com.yahoo.document.Field) ImmutableSDField(com.yahoo.searchdefinition.document.ImmutableSDField) SDField(com.yahoo.searchdefinition.document.SDField) ImmutableSDField(com.yahoo.searchdefinition.document.ImmutableSDField) ImmutableSDField(com.yahoo.searchdefinition.document.ImmutableSDField)

Example 12 with SummaryField

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

the class ImplicitSummaryFields method process.

@Override
public void process(boolean validate) {
    for (DocumentSummary docsum : search.getSummaries().values()) {
        addField(docsum, new SummaryField("rankfeatures", DataType.STRING, SummaryTransform.RANKFEATURES), validate);
        addField(docsum, new SummaryField("summaryfeatures", DataType.STRING, SummaryTransform.SUMMARYFEATURES), validate);
    }
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary)

Example 13 with SummaryField

use of com.yahoo.vespa.documentmodel.SummaryField 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 14 with SummaryField

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

the class AddAttributeTransformToSummaryOfImportedFieldsTest method createDocumentSummary.

private static DocumentSummary createDocumentSummary(String fieldName) {
    DocumentSummary summary = new DocumentSummary("mysummary");
    summary.add(new SummaryField(fieldName, DataType.INT));
    return summary;
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary)

Example 15 with SummaryField

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

the class ValidateFieldTypesTest method createDocumentSummary.

private static DocumentSummary createDocumentSummary(String fieldName, DataType dataType) {
    DocumentSummary summary = new DocumentSummary("mysummary");
    summary.add(new SummaryField(fieldName, dataType));
    return summary;
}
Also used : SummaryField(com.yahoo.vespa.documentmodel.SummaryField) DocumentSummary(com.yahoo.vespa.documentmodel.DocumentSummary)

Aggregations

SummaryField (com.yahoo.vespa.documentmodel.SummaryField)26 DocumentSummary (com.yahoo.vespa.documentmodel.DocumentSummary)10 Attribute (com.yahoo.searchdefinition.document.Attribute)3 SDField (com.yahoo.searchdefinition.document.SDField)3 Index (com.yahoo.searchdefinition.Index)2 Search (com.yahoo.searchdefinition.Search)2 SummaryTransform (com.yahoo.vespa.documentmodel.SummaryTransform)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2 Pair (com.yahoo.collections.Pair)1 DataType (com.yahoo.document.DataType)1 Field (com.yahoo.document.Field)1 TensorDataType (com.yahoo.document.TensorDataType)1 BooleanIndexDefinition (com.yahoo.searchdefinition.document.BooleanIndexDefinition)1 ImmutableSDField (com.yahoo.searchdefinition.document.ImmutableSDField)1 SDDocumentType (com.yahoo.searchdefinition.document.SDDocumentType)1 Source (com.yahoo.vespa.documentmodel.SummaryField.Source)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1