org.elasticsearch.ingest.RandomDocumentPicks Java Examples
The following examples show how to use
org.elasticsearch.ingest.RandomDocumentPicks.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CsvProcessorTests.java From elasticsearch-ingest-csv with Apache License 2.0 | 6 votes |
public void testMismatchLength() throws Exception { Map<String, Object> documentShort = new HashMap<>(); documentShort.put("source_field", "a_value"); IngestDocument ingestDocumentShort = RandomDocumentPicks.randomIngestDocument(random(), documentShort); CsvProcessor processor = new CsvProcessor(randomAlphaOfLength(10), "source_field", defaultColumns, '\"', ',',4096); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> processor.execute(ingestDocumentShort)); assertThat(e.getMessage(), equalTo("field[source_field] size [1] doesn't match header size [" + defaultColumns.size() + "].")); Map<String, Object> documentLong = new HashMap<>(); documentLong.put("source_field", "a_value,b_value,c_value"); IngestDocument ingestDocumentLong = RandomDocumentPicks.randomIngestDocument(random(), documentLong); e = expectThrows(IllegalArgumentException.class, () -> processor.execute(ingestDocumentLong)); assertThat(e.getMessage(), equalTo("field[source_field] size [3] doesn't match header size [" + defaultColumns.size() + "].")); }
Example #2
Source File: CsvProcessorTests.java From elasticsearch-ingest-csv with Apache License 2.0 | 6 votes |
public void testManyTimes() throws Exception { CsvProcessor processor = new CsvProcessor(randomAlphaOfLength(10), "source_field", defaultColumns, '\"', ',',4096); int times = 50000; logger.info("start"); long startTime = System.currentTimeMillis(); for (int i = 0; i < times; i++) { Map<String, Object> document = new HashMap<>(); document.put("source_field", "a_value, b_value"); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document); Map<String, Object> data = processor.execute(ingestDocument).getSourceAndMetadata(); assertThat(data, hasKey("a")); assertThat(data.get("a"), is("a_value")); assertThat(data, hasKey("b")); assertThat(data.get("b"), is("b_value")); } logger.info("end. Loop is " + times + " times. Process Time is " + String.valueOf(System.currentTimeMillis() - startTime) + " ms"); }
Example #3
Source File: CsvProcessorTests.java From elasticsearch-ingest-csv with Apache License 2.0 | 5 votes |
public void testSimple() throws Exception { Map<String, Object> document = new HashMap<>(); document.put("source_field", "a_value, b_value"); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document); CsvProcessor processor = new CsvProcessor(randomAlphaOfLength(10), "source_field", defaultColumns, '\"', ',',4096); Map<String, Object> data = processor.execute(ingestDocument).getSourceAndMetadata(); assertThat(data, hasKey("a")); assertThat(data.get("a"), is("a_value")); assertThat(data, hasKey("b")); assertThat(data.get("b"), is("b_value")); }
Example #4
Source File: CsvProcessorTests.java From elasticsearch-ingest-csv with Apache License 2.0 | 5 votes |
public void testEmptyField() throws Exception { Map<String, Object> document = new HashMap<>(); document.put("source_field", ""); IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), document); CsvProcessor processor = new CsvProcessor(randomAlphaOfLength(10), "source_field", defaultColumns, '\"', ',',4096); IllegalArgumentException e = expectThrows(IllegalArgumentException.class, () -> processor.execute(ingestDocument)); assertThat(e.getMessage(), equalTo("field[source_field] is empty string.")); }
Example #5
Source File: OpenNlpProcessorTests.java From elasticsearch-ingest-opennlp with Apache License 2.0 | 4 votes |
private IngestDocument getIngestDocument(String content) throws Exception { Map<String, Object> document = new HashMap<>(); document.put("source_field", content); return RandomDocumentPicks.randomIngestDocument(random(), document); }