Search in sources :

Example 91 with IngestDocument

use of org.opensearch.ingest.IngestDocument in project OpenSearch by opensearch-project.

the class GeoIpProcessorTests method testNonExistentWithIgnoreMissing.

public void testNonExistentWithIgnoreMissing() throws Exception {
    GeoIpProcessor processor = new GeoIpProcessor(randomAlphaOfLength(10), null, "source_field", loader("/GeoLite2-City.mmdb"), "target_field", EnumSet.allOf(GeoIpProcessor.Property.class), true, new GeoIpCache(1000), false);
    IngestDocument originalIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), Collections.emptyMap());
    IngestDocument ingestDocument = new IngestDocument(originalIngestDocument);
    processor.execute(ingestDocument);
    assertIngestDocument(originalIngestDocument, ingestDocument);
}
Also used : IngestDocumentMatcher.assertIngestDocument(org.opensearch.ingest.IngestDocumentMatcher.assertIngestDocument) IngestDocument(org.opensearch.ingest.IngestDocument) GeoIpCache(org.opensearch.ingest.geoip.IngestGeoIpPlugin.GeoIpCache)

Example 92 with IngestDocument

use of org.opensearch.ingest.IngestDocument in project OpenSearch by opensearch-project.

the class SetProcessorTests method testSetMetadataVersionType.

public void testSetMetadataVersionType() throws Exception {
    String versionType = randomFrom("internal", "external", "external_gte");
    Processor processor = createSetProcessor(Metadata.VERSION_TYPE.getFieldName(), versionType, true, false);
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    processor.execute(ingestDocument);
    assertThat(ingestDocument.getFieldValue(Metadata.VERSION_TYPE.getFieldName(), String.class), Matchers.equalTo(versionType));
}
Also used : Processor(org.opensearch.ingest.Processor) IngestDocument(org.opensearch.ingest.IngestDocument)

Example 93 with IngestDocument

use of org.opensearch.ingest.IngestDocument in project OpenSearch by opensearch-project.

the class SetProcessorTests method testSetNewFieldWithOverrideDisabled.

public void testSetNewFieldWithOverrideDisabled() throws Exception {
    IngestDocument ingestDocument = new IngestDocument(new HashMap<>(), new HashMap<>());
    String fieldName = RandomDocumentPicks.randomFieldName(random());
    Object fieldValue = RandomDocumentPicks.randomFieldValue(random());
    Processor processor = createSetProcessor(fieldName, fieldValue, false, false);
    processor.execute(ingestDocument);
    assertThat(ingestDocument.hasField(fieldName), equalTo(true));
    assertThat(ingestDocument.getFieldValue(fieldName, Object.class), equalTo(fieldValue));
}
Also used : Processor(org.opensearch.ingest.Processor) IngestDocument(org.opensearch.ingest.IngestDocument)

Example 94 with IngestDocument

use of org.opensearch.ingest.IngestDocument in project OpenSearch by opensearch-project.

the class SetProcessorTests method testSetMetadataVersion.

public void testSetMetadataVersion() throws Exception {
    long version = randomNonNegativeLong();
    Processor processor = createSetProcessor(Metadata.VERSION.getFieldName(), version, true, false);
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random());
    processor.execute(ingestDocument);
    assertThat(ingestDocument.getFieldValue(Metadata.VERSION.getFieldName(), Long.class), Matchers.equalTo(version));
}
Also used : Processor(org.opensearch.ingest.Processor) IngestDocument(org.opensearch.ingest.IngestDocument)

Example 95 with IngestDocument

use of org.opensearch.ingest.IngestDocument in project OpenSearch by opensearch-project.

the class SetProcessorTests method testSetNewFields.

public void testSetNewFields() throws Exception {
    IngestDocument ingestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    // used to verify that there are no conflicts between subsequent fields going to be added
    IngestDocument testIngestDocument = RandomDocumentPicks.randomIngestDocument(random(), new HashMap<>());
    Object fieldValue = RandomDocumentPicks.randomFieldValue(random());
    String fieldName = RandomDocumentPicks.addRandomField(random(), testIngestDocument, fieldValue);
    Processor processor = createSetProcessor(fieldName, fieldValue, true, false);
    processor.execute(ingestDocument);
    assertThat(ingestDocument.hasField(fieldName), equalTo(true));
    assertThat(ingestDocument.getFieldValue(fieldName, Object.class), equalTo(fieldValue));
}
Also used : Processor(org.opensearch.ingest.Processor) IngestDocument(org.opensearch.ingest.IngestDocument)

Aggregations

IngestDocument (org.opensearch.ingest.IngestDocument)252 IngestDocumentMatcher.assertIngestDocument (org.opensearch.ingest.IngestDocumentMatcher.assertIngestDocument)150 Processor (org.opensearch.ingest.Processor)136 Matchers.containsString (org.hamcrest.Matchers.containsString)98 HashMap (java.util.HashMap)86 ArrayList (java.util.ArrayList)51 Map (java.util.Map)37 List (java.util.List)36 GeoIpCache (org.opensearch.ingest.geoip.IngestGeoIpPlugin.GeoIpCache)19 OpenSearchTestCase (org.opensearch.test.OpenSearchTestCase)13 TestProcessor (org.opensearch.ingest.TestProcessor)12 SortOrder (org.opensearch.ingest.common.SortProcessor.SortOrder)12 Arrays (java.util.Arrays)11 Collectors (java.util.stream.Collectors)11 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)11 LinkedHashMap (java.util.LinkedHashMap)9 RandomDocumentPicks (org.opensearch.ingest.RandomDocumentPicks)9 Name (com.carrotsearch.randomizedtesting.annotations.Name)7 ParametersFactory (com.carrotsearch.randomizedtesting.annotations.ParametersFactory)7 LinkedList (java.util.LinkedList)7