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);
}
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);
}
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));
}
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);
}
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;
}
Aggregations