use of com.yahoo.vespa.documentmodel.DocumentSummary in project vespa by vespa-engine.
the class ImplicitSummaries method collectSummaries.
private void collectSummaries(SDField field, Search search, boolean validate) {
SummaryField addedSummaryField = null;
// Implicit
String fieldName = field.getName();
SummaryField fieldSummaryField = field.getSummaryField(fieldName);
if (fieldSummaryField == null && field.doesSummarying()) {
fieldSummaryField = new SummaryField(fieldName, field.getDataType());
fieldSummaryField.setImplicit(true);
addSummaryFieldSources(fieldSummaryField, field);
fieldSummaryField.addDestination("default");
field.addSummaryField(fieldSummaryField);
addedSummaryField = fieldSummaryField;
}
if (fieldSummaryField != null) {
for (String dest : fieldSummaryField.getDestinations()) {
DocumentSummary summary = search.getSummary(dest);
if (summary != null) {
summary.add(fieldSummaryField);
}
}
}
// Attribute prefetch
for (Attribute attribute : field.getAttributes().values()) {
if (attribute.getName().equals(fieldName)) {
if (addedSummaryField != null) {
addedSummaryField.setTransform(SummaryTransform.ATTRIBUTE);
}
if (attribute.isPrefetch()) {
addPrefetchAttribute(attribute, field, search);
}
}
}
// Position attributes
if (field.doesSummarying()) {
for (Attribute attribute : field.getAttributes().values()) {
if (!attribute.isPosition())
continue;
DocumentSummary attributePrefetchSummary = getOrCreateAttributePrefetchSummary(search);
attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getDistanceSummaryFieldName(fieldName)));
attributePrefetchSummary.add(field.getSummaryField(PositionDataType.getPositionSummaryFieldName(fieldName)));
}
}
// Explicits
for (SummaryField summaryField : field.getSummaryFields()) {
// Make sure we fetch from attribute here too
Attribute attribute = field.getAttributes().get(fieldName);
if (attribute != null && summaryField.getTransform() == SummaryTransform.NONE) {
summaryField.setTransform(SummaryTransform.ATTRIBUTE);
}
if (isValid(summaryField, search, validate)) {
addToDestinations(summaryField, search);
}
}
}
use of com.yahoo.vespa.documentmodel.DocumentSummary in project vespa by vespa-engine.
the class SummaryConsistency method process.
@Override
public void process(boolean validate) {
for (DocumentSummary summary : search.getSummaries().values()) {
if (summary.getName().equals("default"))
continue;
for (SummaryField summaryField : summary.getSummaryFields()) {
assertConsistency(summaryField, search, validate);
makeAttributeTransformIfAppropriate(summaryField, search);
}
}
}
use of com.yahoo.vespa.documentmodel.DocumentSummary in project vespa by vespa-engine.
the class ValidateFieldTypes method process.
@Override
public void process(boolean validate) {
if (!validate)
return;
String searchName = search.getName();
Map<String, DataType> seenFields = new HashMap<>();
search.allFields().forEach(field -> {
checkFieldType(searchName, "index field", field.getName(), field.getDataType(), seenFields);
for (Map.Entry<String, Attribute> entry : field.getAttributes().entrySet()) {
checkFieldType(searchName, "attribute", entry.getKey(), entry.getValue().getDataType(), seenFields);
}
});
for (DocumentSummary summary : search.getSummaries().values()) {
for (SummaryField field : summary.getSummaryFields()) {
checkFieldType(searchName, "summary field", field.getName(), field.getDataType(), seenFields);
}
}
}
Aggregations