Search in sources :

Example 11 with DocumentType

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

the class DocumentScriptTestCase method newFieldUpdate.

private static DocumentUpdate newFieldUpdate(FieldValue documentFieldValue, FieldValue extraFieldValue) {
    DocumentType type = newDocumentType();
    DocumentUpdate update = new DocumentUpdate(type, "doc:scheme:");
    if (documentFieldValue != null) {
        update.addFieldUpdate(FieldUpdate.createAssign(type.getField("documentField"), documentFieldValue));
    }
    if (extraFieldValue != null) {
        update.addFieldUpdate(FieldUpdate.createAssign(type.getField("extraField"), extraFieldValue));
    }
    return update;
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType)

Example 12 with DocumentType

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

the class DocumentScriptTestCase method newPathUpdate.

private static DocumentUpdate newPathUpdate(FieldValue documentFieldValue, FieldValue extraFieldValue) {
    DocumentType type = newDocumentType();
    DocumentUpdate update = new DocumentUpdate(type, "doc:scheme:");
    if (documentFieldValue != null) {
        update.addFieldPathUpdate(new AssignFieldPathUpdate(type, "documentField", documentFieldValue));
    }
    if (extraFieldValue != null) {
        update.addFieldPathUpdate(new AssignFieldPathUpdate(type, "extraField", extraFieldValue));
    }
    return update;
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate)

Example 13 with DocumentType

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

the class DocumentScriptTestCase method processFieldUpdate.

private static ValueUpdate<?> processFieldUpdate(FieldValue fieldValue) {
    DocumentType docType = new DocumentType("myDocumentType");
    docType.addField("myField", fieldValue.getDataType());
    DocumentUpdate update = new DocumentUpdate(docType, "doc:scheme:");
    update.addFieldUpdate(FieldUpdate.createAssign(docType.getField("myField"), fieldValue));
    update = newScript(docType).execute(ADAPTER_FACTORY, update);
    return update.getFieldUpdate("myField").getValueUpdate(0);
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType)

Example 14 with DocumentType

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

the class DocumentScriptTestCase method processDocument.

private static FieldValue processDocument(FieldValue fieldValue) {
    DocumentType docType = new DocumentType("myDocumentType");
    docType.addField("myField", fieldValue.getDataType());
    Document doc = new Document(docType, "doc:scheme:");
    doc.setFieldValue("myField", fieldValue.clone());
    doc = newScript(docType).execute(ADAPTER_FACTORY, doc);
    return doc.getFieldValue("myField");
}
Also used : DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document)

Example 15 with DocumentType

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

the class DocumentScriptTestCase method processPathUpdate.

private static ValueUpdate<?> processPathUpdate(FieldValue fieldValue) {
    DocumentType docType = new DocumentType("myDocumentType");
    docType.addField("myField", fieldValue.getDataType());
    DocumentUpdate update = new DocumentUpdate(docType, "doc:scheme:");
    update.addFieldPathUpdate(new AssignFieldPathUpdate(docType, "myField", fieldValue));
    update = newScript(docType).execute(ADAPTER_FACTORY, update);
    return update.getFieldUpdate("myField").getValueUpdate(0);
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) AssignFieldPathUpdate(com.yahoo.document.fieldpathupdate.AssignFieldPathUpdate)

Aggregations

DocumentType (com.yahoo.document.DocumentType)98 Test (org.junit.Test)45 Document (com.yahoo.document.Document)41 DocumentPut (com.yahoo.document.DocumentPut)35 Field (com.yahoo.document.Field)24 StringFieldValue (com.yahoo.document.datatypes.StringFieldValue)24 DocumentId (com.yahoo.document.DocumentId)20 ByteArrayInputStream (java.io.ByteArrayInputStream)19 InputStream (java.io.InputStream)19 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)17 DocumentParseInfo (com.yahoo.document.json.readers.DocumentParseInfo)17 VespaJsonDocumentReader (com.yahoo.document.json.readers.VespaJsonDocumentReader)17 DocumentUpdate (com.yahoo.document.DocumentUpdate)15 IntegerFieldValue (com.yahoo.document.datatypes.IntegerFieldValue)15 StructDataType (com.yahoo.document.StructDataType)14 TensorDataType (com.yahoo.document.TensorDataType)12 TensorFieldValue (com.yahoo.document.datatypes.TensorFieldValue)11 ArrayDataType (com.yahoo.document.ArrayDataType)10 MapDataType (com.yahoo.document.MapDataType)10 ReferenceDataType (com.yahoo.document.ReferenceDataType)10