浏览代码

[fix] JSON Processor was not properly added (#20613)

Tal Levy 9 年之前
父节点
当前提交
92ab44d35c

+ 1 - 0
modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/IngestCommonPlugin.java

@@ -62,6 +62,7 @@ public class IngestCommonPlugin extends Plugin implements IngestPlugin {
         processors.put(GrokProcessor.TYPE, new GrokProcessor.Factory(builtinPatterns));
         processors.put(ScriptProcessor.TYPE, new ScriptProcessor.Factory(parameters.scriptService));
         processors.put(DotExpanderProcessor.TYPE, new DotExpanderProcessor.Factory());
+        processors.put(JsonProcessor.TYPE, new JsonProcessor.Factory());
         return Collections.unmodifiableMap(processors);
     }
 

+ 10 - 9
modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/10_basic.yaml

@@ -19,12 +19,13 @@
     - match:  { nodes.$master.ingest.processors.7.type: grok }
     - match:  { nodes.$master.ingest.processors.8.type: gsub }
     - match:  { nodes.$master.ingest.processors.9.type: join }
-    - match:  { nodes.$master.ingest.processors.10.type: lowercase }
-    - match:  { nodes.$master.ingest.processors.11.type: remove }
-    - match:  { nodes.$master.ingest.processors.12.type: rename }
-    - match:  { nodes.$master.ingest.processors.13.type: script }
-    - match:  { nodes.$master.ingest.processors.14.type: set }
-    - match:  { nodes.$master.ingest.processors.15.type: sort }
-    - match:  { nodes.$master.ingest.processors.16.type: split }
-    - match:  { nodes.$master.ingest.processors.17.type: trim }
-    - match:  { nodes.$master.ingest.processors.18.type: uppercase }
+    - match:  { nodes.$master.ingest.processors.10.type: json }
+    - match:  { nodes.$master.ingest.processors.11.type: lowercase }
+    - match:  { nodes.$master.ingest.processors.12.type: remove }
+    - match:  { nodes.$master.ingest.processors.13.type: rename }
+    - match:  { nodes.$master.ingest.processors.14.type: script }
+    - match:  { nodes.$master.ingest.processors.15.type: set }
+    - match:  { nodes.$master.ingest.processors.16.type: sort }
+    - match:  { nodes.$master.ingest.processors.17.type: split }
+    - match:  { nodes.$master.ingest.processors.18.type: trim }
+    - match:  { nodes.$master.ingest.processors.19.type: uppercase }

+ 40 - 0
modules/ingest-common/src/test/resources/rest-api-spec/test/ingest/140_json.yaml

@@ -0,0 +1,40 @@
+---
+teardown:
+  - do:
+      ingest.delete_pipeline:
+        id: "1"
+        ignore: 404
+
+---
+"Test JSON Processor":
+  - do:
+      ingest.put_pipeline:
+        id: "1"
+        body:  >
+          {
+            "processors": [
+              {
+                "json" : {
+                  "field" : "foo"
+                }
+              }
+            ]
+          }
+  - match: { acknowledged: true }
+
+  - do:
+      index:
+        index: test
+        type: test
+        id: 1
+        pipeline: "1"
+        body: {
+          foo: "{\"hello\": \"world\"}"
+        }
+
+  - do:
+      get:
+        index: test
+        type: test
+        id: 1
+  - match: { _source.foo.hello: "world" }