Search in sources :

Example 56 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.

the class ExactExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    StringFieldValue input = (StringFieldValue) ctx.getValue();
    if (input.getString().isEmpty()) {
        return;
    }
    StringFieldValue output = input.clone();
    ctx.setValue(output);
    String prev = output.getString();
    String next = toLowerCase(prev);
    SpanList root = new SpanList();
    SpanTree tree = new SpanTree(SpanTrees.LINGUISTICS, root);
    SpanNode node = new Span(0, prev.length());
    tree.annotate(node, new Annotation(AnnotationTypes.TERM, next.equals(prev) ? null : new StringFieldValue(next)));
    tree.annotate(node, new Annotation(AnnotationTypes.TOKEN_TYPE, new IntegerFieldValue(TokenType.ALPHABETIC.getValue())));
    root.add(node);
    output.setSpanTree(tree);
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) IntegerFieldValue(com.yahoo.document.datatypes.IntegerFieldValue)

Example 57 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.

the class SplitExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    String input = String.valueOf(ctx.getValue());
    Array<StringFieldValue> output = new Array<>(DataType.getArray(DataType.STRING));
    if (!input.isEmpty()) {
        String[] splits = splitPattern.split(input);
        for (String split : splits) {
            output.add(new StringFieldValue(split));
        }
    }
    ctx.setValue(output);
}
Also used : Array(com.yahoo.document.datatypes.Array) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue)

Example 58 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.

the class SubstringExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    String input = String.valueOf(ctx.getValue());
    int len = input.length();
    if (from >= len) {
        input = "";
    } else if (to >= len) {
        input = input.substring(from);
    } else {
        input = input.substring(from, to);
    }
    ctx.setValue(new StringFieldValue(input));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue)

Example 59 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.

the class SwitchExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    FieldValue input = ctx.getValue();
    Expression exp = null;
    if (input != null) {
        if (!(input instanceof StringFieldValue)) {
            throw new IllegalArgumentException("Expected " + DataType.STRING.getName() + " input, got " + input.getDataType().getName() + ".");
        }
        exp = cases.get(String.valueOf(input));
    }
    if (exp == null) {
        exp = defaultExp;
    }
    if (exp != null) {
        exp.execute(ctx);
    }
    ctx.setValue(input);
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldValue(com.yahoo.document.datatypes.FieldValue)

Example 60 with StringFieldValue

use of com.yahoo.document.datatypes.StringFieldValue in project vespa by vespa-engine.

the class JsonRendererTestCase method createHitWithOnlyHiddenFields.

private Hit createHitWithOnlyHiddenFields() {
    Hit h = new Hit("hiddenFields");
    h.setField("NaN", NanNumber.NaN);
    h.setField("emptyString", "");
    h.setField("emptyStringFieldValue", new StringFieldValue(""));
    h.setField("$vespaImplementationDetail", "Hello, World!");
    return h;
}
Also used : FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue)

Aggregations

StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)210 Test (org.junit.Test)136 FieldValue (com.yahoo.document.datatypes.FieldValue)49 SimpleTestAdapter (com.yahoo.vespa.indexinglanguage.SimpleTestAdapter)40 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)37 Document (com.yahoo.document.Document)30 Array (com.yahoo.document.datatypes.Array)25 DocumentType (com.yahoo.document.DocumentType)21 LongFieldValue (com.yahoo.document.datatypes.LongFieldValue)21 Struct (com.yahoo.document.datatypes.Struct)21 DocumentPut (com.yahoo.document.DocumentPut)20 GrowableByteBuffer (com.yahoo.io.GrowableByteBuffer)20 MapFieldValue (com.yahoo.document.datatypes.MapFieldValue)18 SpanTree (com.yahoo.document.annotation.SpanTree)15 FieldUpdate (com.yahoo.document.update.FieldUpdate)15 DocumentUpdate (com.yahoo.document.DocumentUpdate)12 Field (com.yahoo.document.Field)12 Annotation (com.yahoo.document.annotation.Annotation)12 FloatFieldValue (com.yahoo.document.datatypes.FloatFieldValue)12 HashMap (java.util.HashMap)12