Search in sources :

Example 16 with DocumentType

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

the class ScriptManagerTestCase method requireThatScriptsAreAppliedToSubType.

@Test
public void requireThatScriptsAreAppliedToSubType() throws ParseException {
    DocumentTypeManager typeMgr = new DocumentTypeManager();
    typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
    DocumentType docType = typeMgr.getDocumentType("newssummary");
    assertNotNull(docType);
    IlscriptsConfig.Builder config = new IlscriptsConfig.Builder();
    config.ilscript(new IlscriptsConfig.Ilscript.Builder().doctype("newssummary").content("index"));
    ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(config), null);
    assertNotNull(scriptMgr.getScript(typeMgr.getDocumentType("newsarticle")));
    assertNull(scriptMgr.getScript(new DocumentType("unknown")));
}
Also used : IlscriptsConfig(com.yahoo.vespa.configdefinition.IlscriptsConfig) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

Example 17 with DocumentType

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

the class ScriptManagerTestCase method requireThatEmptyConfigurationDoesNotThrow.

@Test
public void requireThatEmptyConfigurationDoesNotThrow() {
    DocumentTypeManager typeMgr = new DocumentTypeManager();
    typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
    ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(new IlscriptsConfig.Builder()), null);
    assertNull(scriptMgr.getScript(new DocumentType("unknown")));
}
Also used : IlscriptsConfig(com.yahoo.vespa.configdefinition.IlscriptsConfig) DocumentTypeManager(com.yahoo.document.DocumentTypeManager) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

Example 18 with DocumentType

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

the class FieldSetRepo method parseFieldCollection.

FieldSet parseFieldCollection(DocumentTypeManager docMan, String docType, String fieldNames) {
    DocumentType type = docMan.getDocumentType(docType);
    if (type == null) {
        throw new IllegalArgumentException("Unknown document type " + docType);
    }
    StringTokenizer tokenizer = new StringTokenizer(fieldNames, ",");
    FieldCollection collection = new FieldCollection(type);
    for (; tokenizer.hasMoreTokens(); ) {
        String token = tokenizer.nextToken();
        Field f = type.getField(token);
        if (f == null) {
            throw new IllegalArgumentException("No such field " + token);
        }
        collection.add(f);
    }
    return collection;
}
Also used : Field(com.yahoo.document.Field) DocumentType(com.yahoo.document.DocumentType) String(java.lang.String)

Example 19 with DocumentType

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

the class IndexingProcessorTestCase method requireThatIndexerForwardsDocumentsOfUnknownType.

@Test
public void requireThatIndexerForwardsDocumentsOfUnknownType() {
    Document input = new Document(new DocumentType("unknown"), "doc:scheme:");
    DocumentOperation output = process(new DocumentPut(input));
    assertTrue(output instanceof DocumentPut);
    assertSame(input, ((DocumentPut) output).getDocument());
}
Also used : DocumentOperation(com.yahoo.document.DocumentOperation) DocumentPut(com.yahoo.document.DocumentPut) DocumentType(com.yahoo.document.DocumentType) Document(com.yahoo.document.Document) Test(org.junit.Test)

Example 20 with DocumentType

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

the class IndexingProcessorTestCase method requireThatIndexerForwardsUpdatesOfUnknownType.

@Test
public void requireThatIndexerForwardsUpdatesOfUnknownType() {
    DocumentUpdate input = new DocumentUpdate(new DocumentType("unknown"), "doc:scheme:");
    DocumentOperation output = process(input);
    assertSame(input, output);
}
Also used : DocumentOperation(com.yahoo.document.DocumentOperation) DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) Test(org.junit.Test)

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