From 59ba4948405cb14d537d6554636e024055bf2a24 Mon Sep 17 00:00:00 2001 From: Hai Yan Date: Tue, 19 Sep 2023 12:29:40 -0500 Subject: [PATCH] Tweak readme and a unit test Signed-off-by: Hai Yan --- data-prepper-plugins/dissect-processor/README.md | 7 +++---- .../plugins/processor/dissect/DissectProcessorTest.java | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data-prepper-plugins/dissect-processor/README.md b/data-prepper-plugins/dissect-processor/README.md index b2dccf04db..84bd7c286e 100644 --- a/data-prepper-plugins/dissect-processor/README.md +++ b/data-prepper-plugins/dissect-processor/README.md @@ -47,11 +47,10 @@ The fields `Date`, `Time`, `Log_Type`, and `Message` have been extracted from `l * `map` (Required): `map` is required to specify the dissect patterns. It takes a `Map` with fields as keys and respective dissect patterns as values. -* `target_types` (Optional): A `Map` that specifies what the target type of specific field should be. By default, all the values are `string`. Target types will be changed after the dissection process. +* `target_types` (Optional): A `Map` that specifies what the target type of specific field should be. Valid options are `integer`, `double`, `string`, and `boolean`. By default, all the values are `string`. Target types will be changed after the dissection process. -* `dissect_when` (Optional): When a conditional statement is configured with `dissect_when`, the processor will evaluate the statement before proceeding with the dissection process. -If the statement evaluates to `true`, the processor will perform the dissection. Else, skipped. +* `dissect_when` (Optional): A Data Prepper Expression string following the [Data Prepper Expression syntax](../../docs/expression_syntax.md). When configured, the processor will evaluate the expression before proceeding with the dissection process and perform the dissection if the expression evaluates to `true`. ## Field Notations @@ -88,7 +87,7 @@ Symbols like `?, +, ->, /, &` can be used to perform logical extraction of dat If the order is not mentioned, the append operation will take place in the order of fields specified in the dissect pattern.

-* **Indirect Field** : While defining a pattern, prefix the field with a `&` to assign the value found with this to the value of another field found. +* **Indirect Field** : While defining a pattern, prefix the field with a `&` to assign the value found with this field to the value of another field found as the key. * **Usage**: Pattern : "%{?field_name}, %{&field_name}" diff --git a/data-prepper-plugins/dissect-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/dissect/DissectProcessorTest.java b/data-prepper-plugins/dissect-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/dissect/DissectProcessorTest.java index d5bdfcbd4b..64bacc7041 100644 --- a/data-prepper-plugins/dissect-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/dissect/DissectProcessorTest.java +++ b/data-prepper-plugins/dissect-processor/src/test/java/org/opensearch/dataprepper/plugins/processor/dissect/DissectProcessorTest.java @@ -257,6 +257,7 @@ void test_target_type_int(){ final List> dissectedRecords = (List>) processor.doExecute(Collections.singletonList(record)); assertTrue(dissectedRecords.get(0).getData().containsKey("field1")); + assertTrue(dissectedRecords.get(0).getData().get("field1", Object.class) instanceof Integer); assertThat(dissectedRecords.get(0).getData().get("field1", Object.class), is(20)); }