Search in sources :

Example 51 with StringFieldValue

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

the class DocumentScriptTestCase method assertSpanTrees.

private static void assertSpanTrees(FieldValue actual, String... expectedSpanTrees) {
    assertTrue(actual instanceof StringFieldValue);
    StringFieldValue str = (StringFieldValue) actual;
    assertEquals(new ArrayList<>(Arrays.asList(expectedSpanTrees)), new ArrayList<>(str.getSpanTreeMap().keySet()));
}
Also used : StringFieldValue(com.yahoo.document.datatypes.StringFieldValue)

Example 52 with StringFieldValue

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

the class JsonRenderer method shouldRender.

private boolean shouldRender(String fieldName, Hit hit) {
    if (debugRendering)
        return true;
    if (fieldName.startsWith(VESPA_HIDDEN_FIELD_PREFIX))
        return false;
    RenderDecision r = lazyRenderAwareCheck(fieldName, hit);
    if (r != RenderDecision.DO_NOT_KNOW)
        return r.booleanValue();
    // this will trigger field decoding, so it is important the lazy decoding magic is done first
    Object field = hit.getField(fieldName);
    if (field instanceof CharSequence && ((CharSequence) field).length() == 0)
        return false;
    // StringFieldValue cannot hold a null, so checking length directly is OK:
    if (field instanceof StringFieldValue && ((StringFieldValue) field).getString().isEmpty())
        return false;
    if (field instanceof NanNumber)
        return false;
    return true;
}
Also used : NanNumber(com.yahoo.search.result.NanNumber) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) JSONObject(org.json.JSONObject)

Example 53 with StringFieldValue

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

the class TokenizeExpression method doExecute.

@Override
protected void doExecute(ExecutionContext context) {
    StringFieldValue input = (StringFieldValue) context.getValue();
    StringFieldValue output = input.clone();
    context.setValue(output);
    AnnotatorConfig cfg = new AnnotatorConfig(config);
    Language lang = context.resolveLanguage(linguistics);
    if (lang != null) {
        cfg.setLanguage(lang);
    }
    LinguisticsAnnotator annotator = new LinguisticsAnnotator(linguistics, cfg);
    annotator.annotate(output);
}
Also used : AnnotatorConfig(com.yahoo.vespa.indexinglanguage.linguistics.AnnotatorConfig) Language(com.yahoo.language.Language) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LinguisticsAnnotator(com.yahoo.vespa.indexinglanguage.linguistics.LinguisticsAnnotator)

Example 54 with StringFieldValue

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

the class Base64EncodeExpression method doExecute.

@Override
protected void doExecute(ExecutionContext ctx) {
    long input = ((LongFieldValue) ctx.getValue()).getLong();
    byte[] output = new byte[8];
    for (int i = 0; i < output.length; ++i) {
        output[i] = (byte) (input & 0xffL);
        input >>>= 8;
    }
    String encoded = new Base64(0).encodeToString(output);
    ctx.setValue(new StringFieldValue(encoded));
}
Also used : Base64(org.apache.commons.codec.binary.Base64) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) LongFieldValue(com.yahoo.document.datatypes.LongFieldValue)

Example 55 with StringFieldValue

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

the class NormalizeExpression method doExecute.

@Override
protected void doExecute(ExecutionContext context) {
    Transformer transformer = linguistics.getTransformer();
    context.setValue(new StringFieldValue(transformer.accentDrop(String.valueOf(context.getValue()), context.resolveLanguage(linguistics))));
}
Also used : Transformer(com.yahoo.language.process.Transformer) 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