{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/38515033","id":38515033,"diff_hunk":"@@ -584,4 +596,96 @@ public void testShardStats() throws IOException {\n         assertTrue(xContent.contains(expectedSubSequence));\n     }\n \n+    private ParsedDocument testParsedDocument(String uid, String id, String type, String routing, long timestamp, long ttl, ParseContext.Document document, BytesReference source, Mapping mappingUpdate) {\n+        Field uidField = new Field(\"_uid\", uid, UidFieldMapper.Defaults.FIELD_TYPE);\n+        Field versionField = new NumericDocValuesField(\"_version\", 0);\n+        document.add(uidField);\n+        document.add(versionField);\n+        return new ParsedDocument(uidField, versionField, id, type, routing, timestamp, ttl, Arrays.asList(document), source, mappingUpdate);\n+    }\n+\n+    public void testPreIndex() throws IOException {\n+        createIndex(\"testpreindex\");\n+        ensureGreen();\n+        IndicesService indicesService = getInstanceFromNode(IndicesService.class);\n+        IndexService test = indicesService.indexService(\"testpreindex\");\n+        IndexShard shard = test.shard(0);\n+        ShardIndexingService shardIndexingService = shard.indexingService();\n+\n+        final HashMap<String, Boolean> listenerInfo = new HashMap<>();\n+        listenerInfo.put(\"preIndexCalled\", false);\n+\n+        shardIndexingService.addListener(new IndexingOperationListener() {\n+            @Override\n+            public Engine.Index preIndex(Engine.Index index) {\n+                listenerInfo.put(\"preIndexCalled\", true);\n+                return super.preIndex(index);\n+            }\n+        });\n+\n+        ParsedDocument doc = testParsedDocument(\"1\", \"1\", \"test\", null, -1, -1, new ParseContext.Document(), new BytesArray(new byte[]{1}), null);\n+        Engine.Index index = new Engine.Index(new Term(\"_uid\", \"1\"), doc);\n+        shard.index(index);\n+        assertTrue(listenerInfo.get(\"preIndexCalled\"));\n+    }\n+\n+    public void testPostIndex() throws IOException {\n+        createIndex(\"testpostindex\");\n+        ensureGreen();\n+        IndicesService indicesService = getInstanceFromNode(IndicesService.class);\n+        IndexService test = indicesService.indexService(\"testpostindex\");\n+        IndexShard shard = test.shard(0);\n+        ShardIndexingService shardIndexingService = shard.indexingService();\n+\n+        final HashMap<String, Boolean> listenerInfo = new HashMap<>();\n+        listenerInfo.put(\"postIndexCalled\", false);\n+\n+        shardIndexingService.addListener(new IndexingOperationListener() {\n+            @Override\n+            public void postIndex(Engine.Index index) {\n+                listenerInfo.put(\"postIndexCalled\", true);\n+                super.postIndex(index);\n+            }\n+        });\n+\n+        ParsedDocument doc = testParsedDocument(\"1\", \"1\", \"test\", null, -1, -1, new ParseContext.Document(), new BytesArray(new byte[]{1}), null);\n+        Engine.Index index = new Engine.Index(new Term(\"_uid\", \"1\"), doc);\n+        shard.index(index);\n+        assertTrue(listenerInfo.get(\"postIndexCalled\"));\n+    }\n+\n+    public void testPostIndexWithException() throws IOException {","path":"core/src/test/java/org/elasticsearch/index/shard/IndexShardTests.java","position":null,"original_position":103,"commit_id":"dbf42ba2978cc5f57900561d91b763637bdfa996","original_commit_id":"17089992e24cd5419959d7b6c494b376df9f0838","user":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"body":"just add one for PostCreate and PostDelete? ","created_at":"2015-09-02T09:50:48Z","updated_at":"2015-09-02T09:50:48Z","html_url":"https://github.com/elastic/elasticsearch/pull/13203#discussion_r38515033","pull_request_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203","_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments/38515033"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/13203#discussion_r38515033"},"pull_request":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203","id":43718333,"html_url":"https://github.com/elastic/elasticsearch/pull/13203","diff_url":"https://github.com/elastic/elasticsearch/pull/13203.diff","patch_url":"https://github.com/elastic/elasticsearch/pull/13203.patch","issue_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13203","number":13203,"state":"open","locked":false,"title":"Add listeners for postIndex, postCreate, and postDelete","user":{"login":"kiryam","id":146705,"avatar_url":"https://avatars.githubusercontent.com/u/146705?v=3","gravatar_id":"","url":"https://api.github.com/users/kiryam","html_url":"https://github.com/kiryam","followers_url":"https://api.github.com/users/kiryam/followers","following_url":"https://api.github.com/users/kiryam/following{/other_user}","gists_url":"https://api.github.com/users/kiryam/gists{/gist_id}","starred_url":"https://api.github.com/users/kiryam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiryam/subscriptions","organizations_url":"https://api.github.com/users/kiryam/orgs","repos_url":"https://api.github.com/users/kiryam/repos","events_url":"https://api.github.com/users/kiryam/events{/privacy}","received_events_url":"https://api.github.com/users/kiryam/received_events","type":"User","site_admin":false},"body":"Closes #13202","created_at":"2015-08-30T18:57:55Z","updated_at":"2015-09-02T09:50:48Z","closed_at":null,"merged_at":null,"merge_commit_sha":"004baf0c48d397674f158b2eb70af065dddf1bfc","assignee":{"login":"s1monw","id":973334,"avatar_url":"https://avatars.githubusercontent.com/u/973334?v=3","gravatar_id":"","url":"https://api.github.com/users/s1monw","html_url":"https://github.com/s1monw","followers_url":"https://api.github.com/users/s1monw/followers","following_url":"https://api.github.com/users/s1monw/following{/other_user}","gists_url":"https://api.github.com/users/s1monw/gists{/gist_id}","starred_url":"https://api.github.com/users/s1monw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/s1monw/subscriptions","organizations_url":"https://api.github.com/users/s1monw/orgs","repos_url":"https://api.github.com/users/s1monw/repos","events_url":"https://api.github.com/users/s1monw/events{/privacy}","received_events_url":"https://api.github.com/users/s1monw/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203/commits","review_comments_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203/comments","review_comment_url":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/elasticsearch/issues/13203/comments","statuses_url":"https://api.github.com/repos/elastic/elasticsearch/statuses/dbf42ba2978cc5f57900561d91b763637bdfa996","head":{"label":"kiryam:master","ref":"master","sha":"dbf42ba2978cc5f57900561d91b763637bdfa996","user":{"login":"kiryam","id":146705,"avatar_url":"https://avatars.githubusercontent.com/u/146705?v=3","gravatar_id":"","url":"https://api.github.com/users/kiryam","html_url":"https://github.com/kiryam","followers_url":"https://api.github.com/users/kiryam/followers","following_url":"https://api.github.com/users/kiryam/following{/other_user}","gists_url":"https://api.github.com/users/kiryam/gists{/gist_id}","starred_url":"https://api.github.com/users/kiryam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiryam/subscriptions","organizations_url":"https://api.github.com/users/kiryam/orgs","repos_url":"https://api.github.com/users/kiryam/repos","events_url":"https://api.github.com/users/kiryam/events{/privacy}","received_events_url":"https://api.github.com/users/kiryam/received_events","type":"User","site_admin":false},"repo":{"id":41638833,"name":"elasticsearch","full_name":"kiryam/elasticsearch","owner":{"login":"kiryam","id":146705,"avatar_url":"https://avatars.githubusercontent.com/u/146705?v=3","gravatar_id":"","url":"https://api.github.com/users/kiryam","html_url":"https://github.com/kiryam","followers_url":"https://api.github.com/users/kiryam/followers","following_url":"https://api.github.com/users/kiryam/following{/other_user}","gists_url":"https://api.github.com/users/kiryam/gists{/gist_id}","starred_url":"https://api.github.com/users/kiryam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kiryam/subscriptions","organizations_url":"https://api.github.com/users/kiryam/orgs","repos_url":"https://api.github.com/users/kiryam/repos","events_url":"https://api.github.com/users/kiryam/events{/privacy}","received_events_url":"https://api.github.com/users/kiryam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kiryam/elasticsearch","description":"Open Source, Distributed, RESTful Search Engine","fork":true,"url":"https://api.github.com/repos/kiryam/elasticsearch","forks_url":"https://api.github.com/repos/kiryam/elasticsearch/forks","keys_url":"https://api.github.com/repos/kiryam/elasticsearch/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kiryam/elasticsearch/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kiryam/elasticsearch/teams","hooks_url":"https://api.github.com/repos/kiryam/elasticsearch/hooks","issue_events_url":"https://api.github.com/repos/kiryam/elasticsearch/issues/events{/number}","events_url":"https://api.github.com/repos/kiryam/elasticsearch/events","assignees_url":"https://api.github.com/repos/kiryam/elasticsearch/assignees{/user}","branches_url":"https://api.github.com/repos/kiryam/elasticsearch/branches{/branch}","tags_url":"https://api.github.com/repos/kiryam/elasticsearch/tags","blobs_url":"https://api.github.com/repos/kiryam/elasticsearch/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kiryam/elasticsearch/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kiryam/elasticsearch/git/refs{/sha}","trees_url":"https://api.github.com/repos/kiryam/elasticsearch/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kiryam/elasticsearch/statuses/{sha}","languages_url":"https://api.github.com/repos/kiryam/elasticsearch/languages","stargazers_url":"https://api.github.com/repos/kiryam/elasticsearch/stargazers","contributors_url":"https://api.github.com/repos/kiryam/elasticsearch/contributors","subscribers_url":"https://api.github.com/repos/kiryam/elasticsearch/subscribers","subscription_url":"https://api.github.com/repos/kiryam/elasticsearch/subscription","commits_url":"https://api.github.com/repos/kiryam/elasticsearch/commits{/sha}","git_commits_url":"https://api.github.com/repos/kiryam/elasticsearch/git/commits{/sha}","comments_url":"https://api.github.com/repos/kiryam/elasticsearch/comments{/number}","issue_comment_url":"https://api.github.com/repos/kiryam/elasticsearch/issues/comments{/number}","contents_url":"https://api.github.com/repos/kiryam/elasticsearch/contents/{+path}","compare_url":"https://api.github.com/repos/kiryam/elasticsearch/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kiryam/elasticsearch/merges","archive_url":"https://api.github.com/repos/kiryam/elasticsearch/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kiryam/elasticsearch/downloads","issues_url":"https://api.github.com/repos/kiryam/elasticsearch/issues{/number}","pulls_url":"https://api.github.com/repos/kiryam/elasticsearch/pulls{/number}","milestones_url":"https://api.github.com/repos/kiryam/elasticsearch/milestones{/number}","notifications_url":"https://api.github.com/repos/kiryam/elasticsearch/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kiryam/elasticsearch/labels{/name}","releases_url":"https://api.github.com/repos/kiryam/elasticsearch/releases{/id}","created_at":"2015-08-30T18:33:15Z","updated_at":"2015-08-30T18:33:35Z","pushed_at":"2015-09-02T09:46:47Z","git_url":"git://github.com/kiryam/elasticsearch.git","ssh_url":"git@github.com:kiryam/elasticsearch.git","clone_url":"https://github.com/kiryam/elasticsearch.git","svn_url":"https://github.com/kiryam/elasticsearch","homepage":"https://www.elastic.co/products/elasticsearch","size":155951,"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:master","ref":"master","sha":"aa26b66e96e62ad43bc7d30fdd37c725a56e2354","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-09-02T08:33:04Z","pushed_at":"2015-09-02T09:49:13Z","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":414734,"stargazers_count":12571,"watchers_count":12571,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4055,"mirror_url":null,"open_issues_count":1193,"forks":4055,"open_issues":1193,"watchers":12571,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203"},"html":{"href":"https://github.com/elastic/elasticsearch/pull/13203"},"issue":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/13203"},"comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/issues/13203/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/elasticsearch/pulls/13203/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/elasticsearch/statuses/dbf42ba2978cc5f57900561d91b763637bdfa996"}}}}