use of com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression in project vespa by vespa-engine.
the class TextMatch method process.
@Override
public void process(boolean validate) {
for (SDField field : search.allConcreteFields()) {
if (field.getMatching().getType() != Matching.Type.TEXT)
continue;
ScriptExpression script = field.getIndexingScript();
if (script == null)
continue;
DataType fieldType = field.getDataType();
if (fieldType instanceof CollectionDataType) {
fieldType = ((CollectionDataType) fieldType).getNestedType();
}
if (fieldType != DataType.STRING)
continue;
Set<String> dynamicSummary = new TreeSet<>();
Set<String> staticSummary = new TreeSet<>();
new IndexingOutputs(search, deployLogger, rankProfileRegistry, queryProfiles).findSummaryTo(search, field, dynamicSummary, staticSummary);
MyVisitor visitor = new MyVisitor(dynamicSummary);
visitor.visit(script);
if (!visitor.requiresTokenize)
continue;
ExpressionConverter converter = new MyStringTokenizer(search, findAnnotatorConfig(search, field));
field.setIndexingScript((ScriptExpression) converter.convert(script));
}
}
use of com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression in project vespa by vespa-engine.
the class OptimizeIlscript method process.
@Override
public void process(boolean validate) {
for (SDField field : search.allConcreteFields()) {
ScriptExpression script = field.getIndexingScript();
if (script == null)
continue;
field.setIndexingScript((ScriptExpression) new ExpressionOptimizer().convert(script));
if (!field.getIndexingScript().toString().equals(script.toString())) {
warn(search, field, "Rewrote ilscript from:\n" + script.toString() + "\nto\n" + field.getIndexingScript().toString());
}
}
}
use of com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression in project vespa by vespa-engine.
the class IndexingInputs method process.
@Override
public void process(boolean validate) {
for (SDField field : search.allConcreteFields()) {
ScriptExpression script = field.getIndexingScript();
if (script == null)
continue;
String fieldName = field.getName();
script = (ScriptExpression) new DefaultToCurrentField(fieldName).convert(script);
script = (ScriptExpression) new EnsureInputExpression(fieldName).convert(script);
if (validate)
new VerifyInputExpression(search, field).visit(script);
field.setIndexingScript(script);
}
}
use of com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression in project vespa by vespa-engine.
the class IndexingOperation method fromStream.
public static IndexingOperation fromStream(SimpleCharStream input, boolean multiLine, Linguistics linguistics) throws ParseException {
ScriptParserContext config = new ScriptParserContext(linguistics);
config.setAnnotatorConfig(new AnnotatorConfig());
config.setInputStream(input);
ScriptExpression exp;
try {
if (multiLine) {
exp = ScriptExpression.newInstance(config);
} else {
exp = new ScriptExpression(StatementExpression.newInstance(config));
}
} catch (com.yahoo.vespa.indexinglanguage.parser.ParseException e) {
ParseException t = new ParseException("Error reported by IL parser: " + e.getMessage());
t.initCause(e);
throw t;
}
return new IndexingOperation(exp);
}
use of com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression in project vespa by vespa-engine.
the class IndexingScriptChangeValidator method validateScripts.
private Optional<VespaConfigChangeAction> validateScripts(SDField currentField, SDField nextField, ValidationOverrides overrides, Instant now) {
ScriptExpression currentScript = currentField.getIndexingScript();
ScriptExpression nextScript = nextField.getIndexingScript();
if (!equalScripts(currentScript, nextScript)) {
ChangeMessageBuilder messageBuilder = new ChangeMessageBuilder(nextField.getName());
new IndexingScriptChangeMessageBuilder(currentSearch, currentField, nextSearch, nextField).populate(messageBuilder);
messageBuilder.addChange("indexing script", currentScript.toString(), nextScript.toString());
return Optional.of(VespaRefeedAction.of(ValidationId.indexingChange.value(), overrides, messageBuilder.build(), now));
}
return Optional.empty();
}
Aggregations