# Elasticsearch plugin - how to hook into ShardIndexingService.addListener?

**URL:** <https://discuss.elastic.co/t/elasticsearch-plugin-how-to-hook-into-shardindexingservice-addlistener/5955>\
**Category:** Elasticsearch\
**Created:** [November 23, 2011, 3:31pm UTC](https://discuss.elastic.co/t/elasticsearch-plugin-how-to-hook-into-shardindexingservice-addlistener/5955 "2011-11-23T15:31:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [November 23, 2011, 3:31pm UTC](https://discuss.elastic.co/t/elasticsearch-plugin-how-to-hook-into-shardindexingservice-addlistener/5955/1 "2011-11-23T15:31:09Z")

</div>

Hello!

I want to code an elasticsearch plugin (via AbstractPlugin) that  
exposes ids for freshly indexed documents. How can I hook into  
ShardIndexingService.addListener()?

I tried to get an instance of ShardIndexingService through the @Inject  
annotation. But that fails with an error.

Constructor is:  
@Inject  
public ChangesAction(Settings settings, Client client, RestController  
controller, ShardIndexingService serv) {  
super(settings, client);  
controller.registerHandler(GET, "/\_changes/", this);  
}

Error is:

1. No implementation for org.elasticsearch.common.settings.Settings  
annotated with @org.elasticsearch.index.settings.IndexSettings() was  
bound.2) Could not find a suitable constructor in  
org.elasticsearch.index.shard.ShardId. Classes must have either one  
(and only one) constructor annotated with @Inject or a zero-argument  
constructor that is not private.

When I remove ShardIndexingService from the constructor I get no error  
(but no ShardIndexingService instance as well).

I think it is a timing issue because ShardIndexingService has not been  
started when my plugin gets initialized.

Any hints where to look?

CU  
Thomas

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [November 24, 2011, 2:14pm UTC](https://discuss.elastic.co/t/elasticsearch-plugin-how-to-hook-into-shardindexingservice-addlistener/5955/2 "2011-11-24T14:14:49Z")

</div>

Have a look at PercolatorService and see how it uses it.

On Wed, Nov 23, 2011 at 5:31 PM, Thomas Peuss [thomas.peuss@nterra.com](mailto:thomas.peuss@nterra.com)wrote:

> Hello!
> 
> I want to code an elasticsearch plugin (via AbstractPlugin) that  
> exposes ids for freshly indexed documents. How can I hook into  
> ShardIndexingService.addListener()?
> 
> I tried to get an instance of ShardIndexingService through the @Inject  
> annotation. But that fails with an error.
> 
> Constructor is:  
> @Inject  
> public ChangesAction(Settings settings, Client client,  
> RestController  
> controller, ShardIndexingService serv) {  
> super(settings, client);  
> controller.registerHandler(GET, "/\_changes/", this);  
> }
> 
> Error is:
> 
> 1. No implementation for org.elasticsearch.common.settings.Settings  
> annotated with @org.elasticsearch.index.settings.IndexSettings() was  
> bound.2) Could not find a suitable constructor in  
> org.elasticsearch.index.shard.ShardId. Classes must have either one  
> (and only one) constructor annotated with @Inject or a zero-argument  
> constructor that is not private.
> 
> When I remove ShardIndexingService from the constructor I get no error  
> (but no ShardIndexingService instance as well).
> 
> I think it is a timing issue because ShardIndexingService has not been  
> started when my plugin gets initialized.
> 
> Any hints where to look?
> 
> CU  
> Thomas

---

<div class="post-metadata">

**Author:** ![Thomas\_Peuss](https://avatars.discourse-cdn.com/v4/letter/t/22d042/32.png) [@Thomas\_Peuss](https://discuss.elastic.co/u/Thomas_Peuss)\
**Post date:** [November 24, 2011, 4:06pm UTC](https://discuss.elastic.co/t/elasticsearch-plugin-how-to-hook-into-shardindexingservice-addlistener/5955/3 "2011-11-24T16:06:05Z")

</div>

Hi Shay!

On 24 Nov., 15:14, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Have a look at PercolatorService and see how it uses it.

Thank you for the hint!

CU  
Thomas

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 3:47am UTC](https://discuss.elastic.co/t/elasticsearch-plugin-how-to-hook-into-shardindexingservice-addlistener/5955/4 "2017-07-06T03:47:33Z")

</div>


