{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/44648205","id":44648205,"diff_hunk":"@@ -0,0 +1,101 @@\n+/*\n+ * Licensed to Elasticsearch under one or more contributor\n+ * license agreements. See the NOTICE file distributed with\n+ * this work for additional information regarding copyright\n+ * ownership. Elasticsearch licenses this file to you under\n+ * the Apache License, Version 2.0 (the \"License\"); you may\n+ * not use this file except in compliance with the License.\n+ * You may obtain a copy of the License at\n+ *\n+ *    http://www.apache.org/licenses/LICENSE-2.0\n+ *\n+ * Unless required by applicable law or agreed to in writing,\n+ * software distributed under the License is distributed on an\n+ * \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+ * KIND, either express or implied.  See the License for the\n+ * specific language governing permissions and limitations\n+ * under the License.\n+ */\n+package org.elasticsearch.plugin.ingest.transport.simulate;\n+\n+import org.elasticsearch.ingest.Data;\n+import org.elasticsearch.ingest.Pipeline;\n+import org.elasticsearch.ingest.processor.ConfigurationUtils;\n+import org.elasticsearch.plugin.ingest.PipelineStore;\n+\n+import java.io.IOException;\n+import java.util.*;\n+\n+public class ParsedSimulateRequest {\n+    private final List<Data> documents;\n+    private final Pipeline pipeline;\n+    private final boolean verbose;\n+\n+    ParsedSimulateRequest(Pipeline pipeline, List<Data> documents, boolean verbose) {\n+        this.pipeline = pipeline;\n+        this.documents = Collections.unmodifiableList(documents);\n+        this.verbose = verbose;\n+    }\n+\n+    public Pipeline getPipeline() {\n+        return pipeline;\n+    }\n+\n+    public List<Data> getDocuments() {\n+        return documents;\n+    }\n+\n+    public boolean isVerbose() {\n+        return verbose;\n+    }\n+\n+    @Override\n+    public boolean equals(Object o) {\n+        if (this == o) return true;\n+        if (o == null || getClass() != o.getClass()) return false;\n+        ParsedSimulateRequest that = (ParsedSimulateRequest) o;\n+        return Objects.equals(verbose, that.verbose) &&\n+                Objects.equals(documents, that.documents) &&\n+                Objects.equals(pipeline, that.pipeline);\n+    }\n+\n+    @Override\n+    public int hashCode() {\n+        return Objects.hash(documents, pipeline, verbose);\n+    }\n+\n+    public static class Parser {\n+        private static final Pipeline.Factory PIPELINE_FACTORY = new Pipeline.Factory();\n+        public static final String SIMULATED_PIPELINE_ID = \"_simulate_pipeline\";\n+\n+        public ParsedSimulateRequest parse(String pipelineId, Map<String, Object> config, boolean verbose, PipelineStore pipelineStore) throws IOException {\n+            Pipeline pipeline;\n+            // if pipeline `id` passed to request, fetch pipeline from store.\n+            if (pipelineId != null) {\n+                pipeline = pipelineStore.get(pipelineId);\n+            } else {\n+                Map<String, Object> pipelineConfig = ConfigurationUtils.readOptionalMap(config, \"pipeline\");\n+                pipeline = PIPELINE_FACTORY.create(SIMULATED_PIPELINE_ID, pipelineConfig, pipelineStore.getProcessorFactoryRegistry());\n+            }\n+\n+            List<Map<String, Object>> docs = ConfigurationUtils.readList(config, \"docs\");\n+\n+            List<Data> dataList = new ArrayList<>();\n+\n+            for (int i = 0; i < docs.size(); i++) {\n+                Map<String, Object> dataMap = docs.get(i);\n+                Map<String, Object> document = ConfigurationUtils.readOptionalMap(dataMap, \"_source\");","path":"plugins/ingest/src/main/java/org/elasticsearch/plugin/ingest/transport/simulate/ParsedSimulateRequest.java","position":87,"original_position":87,"commit_id":"674084973dbdb5147c2d3e448dc1faf2ef861d7e","original_commit_id":"674084973dbdb5147c2d3e448dc1faf2ef861d7e","user":{"login":"javanna","id":832460,"avatar_url":"https://avatars.githubusercontent.com/u/832460?v=3","gravatar_id":"","url":"https://api.github.com/users/javanna","html_url":"https://github.com/javanna","followers_url":"https://api.github.com/users/javanna/followers","following_url":"https://api.github.com/users/javanna/following{/other_user}","gists_url":"https://api.github.com/users/javanna/gists{/gist_id}","starred_url":"https://api.github.com/users/javanna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javanna/subscriptions","organizations_url":"https://api.github.com/users/javanna/orgs","repos_url":"https://api.github.com/users/javanna/repos","events_url":"https://api.github.com/users/javanna/events{/privacy}","received_events_url":"https://api.github.com/users/javanna/received_events","type":"User","site_admin":false},"body":"can we define constants for _source, _index, _type, _id etc. if we use them in more than one place?","created_at":"2015-11-12T11:47:38Z","updated_at":"2015-11-12T11:47:38Z","html_url":"https://github.com/elastic/elasticsearch/pull/14572#discussion_r44648205","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/44648205"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/14572#discussion_r44648205"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572","id":49901194,"html_url":"https://github.com/elastic/elasticsearch/pull/14572","diff_url":"https://github.com/elastic/elasticsearch/pull/14572.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/14572.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14572","number":14572,"state":"open","locked":false,"title":"[Ingest] Simulate Endpoint","user":{"login":"talevy","id":388837,"avatar_url":"https://avatars.githubusercontent.com/u/388837?v=3","gravatar_id":"","url":"https://api.github.com/users/talevy","html_url":"https://github.com/talevy","followers_url":"https://api.github.com/users/talevy/followers","following_url":"https://api.github.com/users/talevy/following{/other_user}","gists_url":"https://api.github.com/users/talevy/gists{/gist_id}","starred_url":"https://api.github.com/users/talevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talevy/subscriptions","organizations_url":"https://api.github.com/users/talevy/orgs","repos_url":"https://api.github.com/users/talevy/repos","events_url":"https://api.github.com/users/talevy/events{/privacy}","received_events_url":"https://api.github.com/users/talevy/received_events","type":"User","site_admin":false},"body":"Still needs work, but good to get some eyes on this","created_at":"2015-11-06T00:25:38Z","updated_at":"2015-11-12T11:47:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b42fae69e1b3e2ddc7e31ded637032cf5ae17340","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/14572/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/674084973dbdb5147c2d3e448dc1faf2ef861d7e","head":{"label":"talevy:simulate_ingest","ref":"simulate_ingest","sha":"674084973dbdb5147c2d3e448dc1faf2ef861d7e","user":{"login":"talevy","id":388837,"avatar_url":"https://avatars.githubusercontent.com/u/388837?v=3","gravatar_id":"","url":"https://api.github.com/users/talevy","html_url":"https://github.com/talevy","followers_url":"https://api.github.com/users/talevy/followers","following_url":"https://api.github.com/users/talevy/following{/other_user}","gists_url":"https://api.github.com/users/talevy/gists{/gist_id}","starred_url":"https://api.github.com/users/talevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talevy/subscriptions","organizations_url":"https://api.github.com/users/talevy/orgs","repos_url":"https://api.github.com/users/talevy/repos","events_url":"https://api.github.com/users/talevy/events{/privacy}","received_events_url":"https://api.github.com/users/talevy/received_events","type":"User","site_admin":false},"repo":{"id":25600001,"name":"elasticsearch","full_name":"talevy/elasticsearch","owner":{"login":"talevy","id":388837,"avatar_url":"https://avatars.githubusercontent.com/u/388837?v=3","gravatar_id":"","url":"https://api.github.com/users/talevy","html_url":"https://github.com/talevy","followers_url":"https://api.github.com/users/talevy/followers","following_url":"https://api.github.com/users/talevy/following{/other_user}","gists_url":"https://api.github.com/users/talevy/gists{/gist_id}","starred_url":"https://api.github.com/users/talevy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/talevy/subscriptions","organizations_url":"https://api.github.com/users/talevy/orgs","repos_url":"https://api.github.com/users/talevy/repos","events_url":"https://api.github.com/users/talevy/events{/privacy}","received_events_url":"https://api.github.com/users/talevy/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/talevy/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/talevy/elasticsearch","forks_url":"https://api.github.com/repos/talevy/elasticsearch/forks","keys_url":"https://api.github.com/repos/talevy/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/talevy/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/talevy/elasticsearch/teams","hooks_url":"https://api.github.com/repos/talevy/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/talevy/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/talevy/elasticsearch/events","assignees_url":"https://api.github.com/repos/talevy/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/talevy/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/talevy/elasticsearch/tags","blobs_url":"https://api.github.com/repos/talevy/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/talevy/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/talevy/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/talevy/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/talevy/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/talevy/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/talevy/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/talevy/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/talevy/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/talevy/elasticsearch/subscription","commits_url":"https://api.github.com/repos/talevy/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/talevy/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/talevy/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/talevy/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/talevy/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/talevy/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/talevy/elasticsearch/merges","archive_url":"https://api.github.com/repos/talevy/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/talevy/elasticsearch/downloads","issues_url":"https://api.github.com/repos/talevy/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/talevy/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/talevy/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/talevy/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/talevy/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/talevy/elasticsearch/releases{/id}","created_at":"2014-10-22T19:25:53Z","updated_at":"2015-04-14T21:19:32Z","pushed_at":"2015-11-12T05:51:53Z","git_url":"git://github.com/talevy/elasticsearch.git","ssh_url":"git@github.com:talevy/elasticsearch.git","clone_url":"https://github.com/talevy/elasticsearch.git","svn_url":"https://github.com/talevy/elasticsearch","homepage":"http://elasticsearch.org","size":159916,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:feature/ingest","ref":"feature/ingest","sha":"c12c9e6e29db2ab364106e642c8f1875679b728c","user":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":507775,"name":"elasticsearch","full_name":"elastic/elasticsearch","owner":{"login":"elastic","id":6764390,"avatar_url":"https://avatars.githubusercontent.com/u/6764390?v=3","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/elastic/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":false,"url":"https://api.github.com/repos/elastic/elasticsearch","forks_url":"https://api.github.com/repos/elastic/elasticsearch/forks","keys_url":"https://api.github.com/repos/elastic/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/elasticsearch/teams","hooks_url":"https://api.github.com/repos/elastic/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/elastic/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/elasticsearch/events","assignees_url":"https://api.github.com/repos/elastic/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/elasticsearch/tags","blobs_url":"https://api.github.com/repos/elastic/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/elastic/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/elastic/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/elastic/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/elastic/elasticsearch/subscription","commits_url":"https://api.github.com/repos/elastic/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/elasticsearch/merges","archive_url":"https://api.github.com/repos/elastic/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/elasticsearch/downloads","issues_url":"https://api.github.com/repos/elastic/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/elastic/elasticsearch/releases{/id}","created_at":"2010-02-08T13:20:56Z","updated_at":"2015-11-12T10:12:17Z","pushed_at":"2015-11-12T10:01:10Z","git_url":"git://github.com/elastic/elasticsearch.git","ssh_url":"git@github.com:elastic/elasticsearch.git","clone_url":"https://github.com/elastic/elasticsearch.git","svn_url":"https://github.com/elastic/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":476665,"stargazers_count":13503,"watchers_count":13503,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4448,"mirror_url":null,"open_issues_count":1324,"forks":4448,"open_issues":1324,"watchers":13503,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/14572"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/14572"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/14572/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/14572/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/674084973dbdb5147c2d3e448dc1faf2ef861d7e"}}}}