Search in sources :

Example 51 with DocumentType

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

the class ScriptManagerTestCase method requireThatScriptsAreAppliedToSuperType.

@Test
public void requireThatScriptsAreAppliedToSuperType() throws ParseException {
    DocumentTypeManager typeMgr = new DocumentTypeManager();
    typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
    DocumentType docType = typeMgr.getDocumentType("newsarticle");
    assertNotNull(docType);
    IlscriptsConfig.Builder config = new IlscriptsConfig.Builder();
    config.ilscript(new IlscriptsConfig.Ilscript.Builder().doctype("newsarticle").content("index"));
    ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(config), null);
    assertNotNull(scriptMgr.getScript(typeMgr.getDocumentType("newssummary")));
    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 52 with DocumentType

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

the class ScriptManagerTestCase method requireThatUnknownDocumentTypeReturnsNull.

@Test
public void requireThatUnknownDocumentTypeReturnsNull() {
    DocumentTypeManager typeMgr = new DocumentTypeManager();
    typeMgr.configure("file:src/test/cfg/documentmanager_inherit.cfg");
    ScriptManager scriptMgr = new ScriptManager(typeMgr, new IlscriptsConfig(new IlscriptsConfig.Builder()), null);
    for (Iterator<DocumentType> it = typeMgr.documentTypeIterator(); it.hasNext(); ) {
        assertNull(scriptMgr.getScript(it.next()));
    }
    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 53 with DocumentType

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

the class IndexingProcessorTestCase method requireThatEmptyDocumentUpdateOutputDoesNotThrow.

@Test
public void requireThatEmptyDocumentUpdateOutputDoesNotThrow() {
    DocumentType inputType = indexer.getDocumentTypeManager().getDocumentType("music");
    DocumentUpdate input = new DocumentUpdate(inputType, "doc:scheme:");
    Processing proc = new Processing();
    proc.getDocumentOperations().add(input);
    indexer.process(proc);
    assertEquals(0, proc.getDocumentOperations().size());
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentType(com.yahoo.document.DocumentType) Processing(com.yahoo.docproc.Processing) Test(org.junit.Test)

Example 54 with DocumentType

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

the class IndexingProcessorTestCase method requireThatIndexerProcessesUpdates.

@Test
public void requireThatIndexerProcessesUpdates() {
    DocumentType inputType = indexer.getDocumentTypeManager().getDocumentType("music");
    DocumentUpdate input = new DocumentUpdate(inputType, "doc:scheme:");
    input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("isbn"), new StringFieldValue("isbnmarker")));
    input.addFieldUpdate(FieldUpdate.createAssign(inputType.getField("artist"), new StringFieldValue("69")));
    DocumentOperation output = process(input);
    assertTrue(output instanceof DocumentUpdate);
    DocumentUpdate docUpdate = (DocumentUpdate) output;
    assertEquals(3, docUpdate.getFieldUpdates().size());
    {
        FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(0);
        assertEquals("song", fieldUpdate.getField().getName());
        assertEquals(1, fieldUpdate.getValueUpdates().size());
        ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("isbnmarker"), valueUpdate.getValue());
        fieldUpdate = docUpdate.getFieldUpdate(1);
        assertEquals("title", fieldUpdate.getField().getName());
        assertEquals(1, fieldUpdate.getValueUpdates().size());
        valueUpdate = fieldUpdate.getValueUpdate(0);
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("69"), valueUpdate.getValue());
    }
    {
        FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(1);
        ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
        assertEquals("title", fieldUpdate.getField().getName());
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("69"), valueUpdate.getValue());
    }
    {
        FieldUpdate fieldUpdate = docUpdate.getFieldUpdate(2);
        ValueUpdate<?> valueUpdate = fieldUpdate.getValueUpdate(0);
        assertEquals("isbn", fieldUpdate.getField().getName());
        assertTrue(valueUpdate instanceof AssignValueUpdate);
        assertEquals(new StringFieldValue("isbnmarker"), valueUpdate.getValue());
    }
}
Also used : ValueUpdate(com.yahoo.document.update.ValueUpdate) AssignValueUpdate(com.yahoo.document.update.AssignValueUpdate) DocumentOperation(com.yahoo.document.DocumentOperation) DocumentUpdate(com.yahoo.document.DocumentUpdate) StringFieldValue(com.yahoo.document.datatypes.StringFieldValue) FieldUpdate(com.yahoo.document.update.FieldUpdate) DocumentType(com.yahoo.document.DocumentType) AssignValueUpdate(com.yahoo.document.update.AssignValueUpdate) Test(org.junit.Test)

Example 55 with DocumentType

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

the class SimpleDocumentProcessorTestCase method requireThatProcessingMultipleOperationsWork.

@Test
public void requireThatProcessingMultipleOperationsWork() {
    DocumentType type = new DocumentType("foobar");
    type.addField("title", DataType.STRING);
    Processing p = getProcessing(new DocumentPut(type, "doc:this:is:a:document"), new DocumentUpdate(type, "doc:this:is:an:update"), new DocumentRemove(new DocumentId("doc:this:is:a:remove")));
    DocprocService service = setupDocprocService(new VerySimpleDocumentProcessor());
    service.getExecutor().process(p);
    assertThat(p.getDocumentOperations().size(), is(3));
    assertThat(p.getDocumentOperations().get(0) instanceof DocumentPut, is(true));
    assertThat(((DocumentPut) p.getDocumentOperations().get(0)).getDocument().getFieldValue("title").getWrappedValue(), is("processed"));
    assertThat(p.getDocumentOperations().get(1) instanceof DocumentUpdate, is(true));
    assertThat(p.getDocumentOperations().get(2) instanceof DocumentRemove, is(true));
    assertThat(p.getDocumentOperations().get(2).getId().toString(), is("userdoc:foobar:1234:something"));
}
Also used : DocumentUpdate(com.yahoo.document.DocumentUpdate) DocumentRemove(com.yahoo.document.DocumentRemove) DocumentPut(com.yahoo.document.DocumentPut) DocumentId(com.yahoo.document.DocumentId) 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