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