Search in sources :

Example 1 with ScriptExpression

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));
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) TreeSet(java.util.TreeSet) CollectionDataType(com.yahoo.document.CollectionDataType) DataType(com.yahoo.document.DataType) CollectionDataType(com.yahoo.document.CollectionDataType) ExpressionConverter(com.yahoo.vespa.indexinglanguage.ExpressionConverter) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)

Example 2 with ScriptExpression

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());
        }
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ExpressionOptimizer(com.yahoo.vespa.indexinglanguage.ExpressionOptimizer) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)

Example 3 with ScriptExpression

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);
    }
}
Also used : SDField(com.yahoo.searchdefinition.document.SDField) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)

Example 4 with ScriptExpression

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);
}
Also used : AnnotatorConfig(com.yahoo.vespa.indexinglanguage.linguistics.AnnotatorConfig) ParseException(com.yahoo.searchdefinition.parser.ParseException) ScriptParserContext(com.yahoo.vespa.indexinglanguage.ScriptParserContext) ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)

Example 5 with ScriptExpression

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();
}
Also used : ScriptExpression(com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)

Aggregations

ScriptExpression (com.yahoo.vespa.indexinglanguage.expressions.ScriptExpression)16 StatementExpression (com.yahoo.vespa.indexinglanguage.expressions.StatementExpression)9 Test (org.junit.Test)8 InputExpression (com.yahoo.vespa.indexinglanguage.expressions.InputExpression)7 SDField (com.yahoo.searchdefinition.document.SDField)6 AttributeExpression (com.yahoo.vespa.indexinglanguage.expressions.AttributeExpression)5 EchoExpression (com.yahoo.vespa.indexinglanguage.expressions.EchoExpression)5 ArithmeticExpression (com.yahoo.vespa.indexinglanguage.expressions.ArithmeticExpression)4 CatExpression (com.yahoo.vespa.indexinglanguage.expressions.CatExpression)4 ForEachExpression (com.yahoo.vespa.indexinglanguage.expressions.ForEachExpression)4 GuardExpression (com.yahoo.vespa.indexinglanguage.expressions.GuardExpression)4 IfThenExpression (com.yahoo.vespa.indexinglanguage.expressions.IfThenExpression)4 IndexExpression (com.yahoo.vespa.indexinglanguage.expressions.IndexExpression)4 ParenthesisExpression (com.yahoo.vespa.indexinglanguage.expressions.ParenthesisExpression)4 SelectInputExpression (com.yahoo.vespa.indexinglanguage.expressions.SelectInputExpression)4 SwitchExpression (com.yahoo.vespa.indexinglanguage.expressions.SwitchExpression)4 Base64DecodeExpression (com.yahoo.vespa.indexinglanguage.expressions.Base64DecodeExpression)3 Base64EncodeExpression (com.yahoo.vespa.indexinglanguage.expressions.Base64EncodeExpression)3 ClearStateExpression (com.yahoo.vespa.indexinglanguage.expressions.ClearStateExpression)3 GetFieldExpression (com.yahoo.vespa.indexinglanguage.expressions.GetFieldExpression)3