Elasticsearch plugin - how to hook into ShardIndexingService.addListener?


(Thomas Peuss) #1

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


(Shay Banon) #2

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.comwrote:

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


(Thomas Peuss) #3

Hi Shay!

On 24 Nov., 15:14, Shay Banon kim...@gmail.com wrote:

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

Thank you for the hint!

CU
Thomas


(system) #4