use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class IndexInfo method derive.
@Override
protected void derive(Search search) {
// Derive per field
super.derive(search);
this.search = search;
// Populate fieldsets with actual field objects, bit late to do that here but
for (FieldSet fs : fieldSets.values()) {
for (String fieldName : fs.getFieldNames()) {
fs.fields().add(search.getField(fieldName));
}
}
// Must follow, because index settings overrides field settings
for (Index index : search.getExplicitIndices()) {
derive(index, search);
}
// TODO: Move to fieldinfo and implement differently. This is not right
for (SummaryField summaryField : search.getUniqueNamedSummaryFields().values()) {
if (summaryField.getTransform().isTeaser()) {
addIndexCommand(summaryField.getName(), CMD_DYNTEASER);
}
if (summaryField.getTransform().isBolded()) {
addIndexCommand(summaryField.getName(), CMD_HIGHLIGHT);
}
}
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class SDField method getSummaryField.
/**
* Returns a summary field defined (implicitly or explicitly) by this field.
*
* @param create true to create the summary field and add it to this field before returning if it is missing
* @return the summary field, or null if not present and create is false
*/
public SummaryField getSummaryField(String name, boolean create) {
SummaryField summaryField = summaryFields.get(name);
if (summaryField == null && create) {
summaryField = new SummaryField(name, getDataType());
addSummaryField(summaryField);
}
return summaryFields.get(name);
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class PredicateProcessor method process.
@Override
public void process(boolean validate) {
for (SDField field : search.allConcreteFields()) {
if (field.getDataType() == DataType.PREDICATE) {
if (validate && field.doesIndexing()) {
fail(search, field, "Use 'attribute' instead of 'index'. This will require a refeed if you have upgraded.");
}
if (field.doesAttributing()) {
Attribute attribute = field.getAttributes().get(field.getName());
for (Index index : field.getIndices().values()) {
BooleanIndexDefinition booleanDefinition = index.getBooleanIndexDefiniton();
if (validate && (booleanDefinition == null || !booleanDefinition.hasArity())) {
fail(search, field, "Missing arity value in predicate field.");
}
if (validate && (booleanDefinition.getArity() < 2)) {
fail(search, field, "Invalid arity value in predicate field, must be greater than 1.");
}
double threshold = booleanDefinition.getDensePostingListThreshold();
if (validate && (threshold <= 0 || threshold > 1)) {
fail(search, field, "Invalid dense-posting-list-threshold value in predicate field. " + "Value must be in range (0..1].");
}
attribute.setArity(booleanDefinition.getArity());
attribute.setLowerBound(booleanDefinition.getLowerBound());
attribute.setUpperBound(booleanDefinition.getUpperBound());
attribute.setDensePostingListThreshold(threshold);
addPredicateOptimizationIlScript(field, booleanDefinition);
}
DocumentSummary summary = search.getSummary("attributeprefetch");
if (summary != null) {
summary.remove(attribute.getName());
}
for (SummaryField summaryField : search.getSummaryFields(field).values()) {
summaryField.setTransform(SummaryTransform.NONE);
}
}
} else if (validate && field.getDataType().getPrimitiveType() == DataType.PREDICATE) {
fail(search, field, "Collections of predicates are not allowed.");
} else if (validate && field.getDataType() == DataType.RAW && field.doesIndexing()) {
fail(search, field, "Indexing of RAW fields is not supported.");
} else if (validate) {
// if field is not a predicate, disallow predicate-related index parameters
for (Index index : field.getIndices().values()) {
if (index.getBooleanIndexDefiniton() != null) {
BooleanIndexDefinition def = index.getBooleanIndexDefiniton();
if (def.hasArity()) {
fail(search, field, "Arity parameter is used only for predicate type fields.");
} else if (def.hasLowerBound() || def.hasUpperBound()) {
fail(search, field, "Parameters lower-bound and upper-bound are used only for predicate type fields.");
} else if (def.hasDensePostingListThreshold()) {
fail(search, field, "Parameter dense-posting-list-threshold is used only for predicate type fields.");
}
}
}
}
}
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class SummaryConsistency method assertConsistency.
private void assertConsistency(SummaryField summaryField, Search search, boolean validate) {
// Compare to default:
SummaryField existingDefault = search.getSummary("default").getSummaryField(summaryField.getName());
if (existingDefault != null) {
if (validate)
assertConsistentTypes(existingDefault, summaryField);
makeConsistentWithDefaultOrThrow(existingDefault, summaryField);
} else {
// If no default, compare to whichever definition of the field
SummaryField existing = search.getExplicitSummaryField(summaryField.getName());
if (existing == null)
return;
if (validate)
assertConsistentTypes(existing, summaryField);
makeConsistentOrThrow(existing, summaryField, search);
}
}
use of com.yahoo.vespa.documentmodel.SummaryField in project vespa by vespa-engine.
the class SummaryToOperation method apply.
public void apply(SDField field) {
SummaryField summary;
summary = field.getSummaryField(name);
if (summary == null) {
summary = new SummaryField(field);
summary.addSource(field.getName());
summary.addDestination("default");
field.addSummaryField(summary);
}
summary.setImplicit(false);
for (String destination : destinations) {
summary.addDestination(destination);
}
}
Aggregations