@Test public void testTokenizer() { Document doc = new Document(createMusicType(), "id:mynamespace:music::1"); doc.setFieldValue(PRODUCT_TYPE_FIELD_NAME, new StringFieldValue("Media > Music & Sound Recordings > Music Cassette Tapes")); Processing p = getProcessing(new DocumentPut(doc)); DocprocService service = setupDocprocService(new ProductTypeTokenizerDocProc()); service.getExecutor().process(p); Array<?> tokens = (Array<?>)doc.getFieldValue(PRODUCT_TYPE_TOKENS_FIELD_NAME); assertEquals(55, tokens.size()); assertEquals("M", tokens.get(0).toString()); assertEquals("Media > Music & Sound Recordings > Music Cassette Tapes", tokens.get(54).toString()); }
@Override public Progress process(Processing processing) { for (DocumentOperation op : processing.getDocumentOperations()) { if (op instanceof DocumentPut) { DocumentPut put = (DocumentPut) op; Document document = put.getDocument(); if (document.getDataType().isA(MUSIC_DOCUMENT_TYPE)) { logger.info("Before processing: " + document.toJson()); processPut(document); logger.info("After processing: " + document.toJson()); return Progress.DONE; } } } return Progress.DONE; }
ProductTypeTokenizerDocProc extends DocumentProcessor { @Override public Progress process(Processing processing) { for (DocumentOperation op : processing.getDocumentOperations()) { if (op instanceof DocumentPut) { DocumentPut put = (DocumentPut) op; Document document = put.getDocument(); if (document.getDataType().isA(MUSIC_DOCUMENT_TYPE)) { logger.info("Before processing: " + document.toJson()); processPut(document); logger.info("After processing: " + document.toJson()); return Progress.DONE; } } } return Progress.DONE; } }
ProductTypeTokenizerDocProc extends DocumentProcessor { @Override public Progress process(Processing processing) { for (DocumentOperation op : processing.getDocumentOperations()) { if (op instanceof DocumentPut) { DocumentPut put = (DocumentPut) op; Document document = put.getDocument(); if (document.getDataType().isA(MUSIC_DOCUMENT_TYPE)) { logger.info("Before processing: " + document.toJson()); processPut(document); logger.info("After processing: " + document.toJson()); return Progress.DONE; } } } return Progress.DONE; }  }
ProductTypeTokenizerDocProc extends DocumentProcessor { @Override public Progress process(Processing processing) { for (DocumentOperation op : processing.getDocumentOperations()) { if (op instanceof DocumentPut) { DocumentPut put = (DocumentPut) op; Document document = put.getDocument(); if (document.getDataType().isA(MUSIC_DOCUMENT_TYPE)) { logger.info("Before processing: " + document.toJson()); processPut(document); logger.info("After processing: " + document.toJson()); return Progress.DONE; } } } return Progress.DONE; }  @Override Progress process(Processing processing); @Override void deconstruct(); }
ProductTypeTokenizerDocProc extends DocumentProcessor { @Override public Progress process(Processing processing) { for (DocumentOperation op : processing.getDocumentOperations()) { if (op instanceof DocumentPut) { DocumentPut put = (DocumentPut) op; Document document = put.getDocument(); if (document.getDataType().isA(MUSIC_DOCUMENT_TYPE)) { logger.info("Before processing: " + document.toJson()); processPut(document); logger.info("After processing: " + document.toJson()); return Progress.DONE; } } } return Progress.DONE; }  @Override Progress process(Processing processing); @Override void deconstruct();  }