Plugin call returns "No handler found for uri"


(Luiz Henrique Zambom Santana) #1

Hello:

I am trying to develop a simple plugin to count terms in a repository using
Lucene and expose the result through a elastic search RestHandler.

I successfully went through these plugins tutorial:


http://elasticsearchserverbook.com/creating-custom-elasticsearch-rest-action/

And I can see that my plugin is installed and loaded.

[2013-11-06 14:47:00,471][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin]
WordFrequencyPlugin settings
[2013-11-06 14:47:00,472][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] name
[2013-11-06 14:47:00,475][INFO ][plugins ] [Starbolt]
loaded [WordFrequencyPlugin], sites []
[2013-11-06 14:47:00,554][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] onModule
[2013-11-06 14:47:02,200][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.CustomRestRegisterAction]
Registering action /_counter/movies

However, when I try:

lsantana@abc:~/elasticsearch-0.90.6/bin$ curl -XGET
'localhost:9200/_counter/movies?term=XPTO'
No handler found for uri [/_counter/movies?term=XPTO] and method
[GET]lsantana@iqserdev10:~/elasticsearch-0.90.6/bin$

My BaseRestHandler looks like this:

public class CustomRestRegisterAction extends BaseRestHandler {

private static Logger log =
Logger.getLogger(CustomRestRegisterAction.class);
public CustomRestRegisterAction(Settings settings, Client client) {
super(settings, client);
}
@Inject
public CustomRestRegisterAction(Settings settings, Client client,
RestController controller) {
super(settings, client);
String path = "/_counter/movies";
controller.registerHandler(Method.GET, path, new
CustomRestRegisterAction(settings, client));
log.info("Registering action "+path);
}

public void handleRequest(RestRequest request, RestChannel channel) {

log.info("Handling request");
String term = request.param("term");

Lucene l = new Lucene();
int frequency = -1;
try {

DirectoryReader directoryReader = new DirectoryReader();
Directory directory = directoryReader.getDocuments();

frequency = l.frequency(term, "city", directory);
} catch (IOException e) {
e.printStackTrace();
}

channel.sendResponse(new StringRestResponse(RestStatus.OK, String
.valueOf(frequency)));
}
}

Any clue about what can be missing?

Best regards,

Luiz

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Ivan Brusic) #2

Did you register your action with the RestModule?

Take a look at Jorg's plugin, which might be similar to yours:

In his plugin defintion, he adds various actions to various modules:

public void onModule(RestModule module) {
    module.addRestAction(RestTermlistAction.class);
}

https://github.com/jprante/elasticsearch-index-termlist/blob/master/src/main/java/org/xbib/elasticsearch/plugin/termlist/IndexTermlistPlugin.java

Cheers,

Ivan

On Wed, Nov 6, 2013 at 6:57 AM, Luiz Henrique Zambom Santana <
lhzsantana@gmail.com> wrote:

Hello:

I am trying to develop a simple plugin to count terms in a repository
using Lucene and expose the result through a elastic search RestHandler.

I successfully went through these plugins tutorial:

http://www.found.no/foundation/writing-a-plugin/

http://elasticsearchserverbook.com/creating-custom-elasticsearch-rest-action/

And I can see that my plugin is installed and loaded.

[2013-11-06 14:47:00,471][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin]
WordFrequencyPlugin settings
[2013-11-06 14:47:00,472][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] name
[2013-11-06 14:47:00,475][INFO ][plugins ] [Starbolt]
loaded [WordFrequencyPlugin], sites []
[2013-11-06 14:47:00,554][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] onModule
[2013-11-06 14:47:02,200][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.CustomRestRegisterAction]
Registering action /_counter/movies

However, when I try:

lsantana@abc:~/elasticsearch-0.90.6/bin$ curl -XGET
'localhost:9200/_counter/movies?term=XPTO'
No handler found for uri [/_counter/movies?term=XPTO] and method
[GET]lsantana@iqserdev10:~/elasticsearch-0.90.6/bin$

My BaseRestHandler looks like this:

public class CustomRestRegisterAction extends BaseRestHandler {

private static Logger log =
Logger.getLogger(CustomRestRegisterAction.class);
public CustomRestRegisterAction(Settings settings, Client client) {
super(settings, client);
}
@Inject
public CustomRestRegisterAction(Settings settings, Client client,
RestController controller) {
super(settings, client);
String path = "/_counter/movies";
controller.registerHandler(Method.GET, path, new
CustomRestRegisterAction(settings, client));
log.info("Registering action "+path);
}

public void handleRequest(RestRequest request, RestChannel channel) {

log.info("Handling request");
String term = request.param("term");

Lucene l = new Lucene();
int frequency = -1;
try {

DirectoryReader directoryReader = new DirectoryReader();
Directory directory = directoryReader.getDocuments();

frequency = l.frequency(term, "city", directory);
} catch (IOException e) {
e.printStackTrace();
}

channel.sendResponse(new StringRestResponse(RestStatus.OK, String
.valueOf(frequency)));
}
}

Any clue about what can be missing?

Best regards,

Luiz

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Luiz Henrique Zambom Santana) #3

Hi Ivan:

Yes, I did. My plugin class is like this:

public class WordFrequencyPlugin extends AbstractPlugin {

private static Logger log = Logger.getLogger(WordFrequencyPlugin.class);

@Inject
public WordFrequencyPlugin(Settings settings) {
log.info("WordFrequencyPlugin settings");
}

@Inject
public WordFrequencyPlugin() {
}

public String description() {
return "Word frequency counter";
}

public String name() {
return "WordFrequencyPlugin";
}

public void onModule(RestModule module) {
module.addRestAction(CustomRestRegisterAction.class);
log.info("onModule");
}
}

I can see that the onModule method is called and that the handler is
registered (the method "CustomRestRegisterAction" is called). In the Jorg's
plugin I see that he register also an action registerAction (below), that I
do not know if it is necessary to my plugin.

public void onModule(ActionModule module) {
    module.registerAction(TermlistAction.INSTANCE,

TransportTermlistAction.class);
}

Can it be what is missing?

Thanks a lot!

2013/11/6 Ivan Brusic ivan@brusic.com

Did you register your action with the RestModule?

Take a look at Jorg's plugin, which might be similar to yours:

https://github.com/jprante/elasticsearch-index-termlist

In his plugin defintion, he adds various actions to various modules:

public void onModule(RestModule module) {
    module.addRestAction(RestTermlistAction.class);
}

https://github.com/jprante/elasticsearch-index-termlist/blob/master/src/main/java/org/xbib/elasticsearch/plugin/termlist/IndexTermlistPlugin.java

Cheers,

Ivan

On Wed, Nov 6, 2013 at 6:57 AM, Luiz Henrique Zambom Santana <
lhzsantana@gmail.com> wrote:

Hello:

I am trying to develop a simple plugin to count terms in a repository
using Lucene and expose the result through a elastic search RestHandler.

I successfully went through these plugins tutorial:

http://www.found.no/foundation/writing-a-plugin/

http://elasticsearchserverbook.com/creating-custom-elasticsearch-rest-action/

And I can see that my plugin is installed and loaded.

[2013-11-06 14:47:00,471][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin]
WordFrequencyPlugin settings
[2013-11-06 14:47:00,472][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] name
[2013-11-06 14:47:00,475][INFO ][plugins ] [Starbolt]
loaded [WordFrequencyPlugin], sites []
[2013-11-06 14:47:00,554][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] onModule
[2013-11-06 14:47:02,200][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.CustomRestRegisterAction]
Registering action /_counter/movies

However, when I try:

lsantana@abc:~/elasticsearch-0.90.6/bin$ curl -XGET
'localhost:9200/_counter/movies?term=XPTO'
No handler found for uri [/_counter/movies?term=XPTO] and method
[GET]lsantana@iqserdev10:~/elasticsearch-0.90.6/bin$

My BaseRestHandler looks like this:

public class CustomRestRegisterAction extends BaseRestHandler {

private static Logger log =
Logger.getLogger(CustomRestRegisterAction.class);
public CustomRestRegisterAction(Settings settings, Client client) {
super(settings, client);
}
@Inject
public CustomRestRegisterAction(Settings settings, Client client,
RestController controller) {
super(settings, client);
String path = "/_counter/movies";
controller.registerHandler(Method.GET, path, new
CustomRestRegisterAction(settings, client));
log.info("Registering action "+path);
}

public void handleRequest(RestRequest request, RestChannel channel) {

log.info("Handling request");
String term = request.param("term");

Lucene l = new Lucene();
int frequency = -1;
try {

DirectoryReader directoryReader = new DirectoryReader();
Directory directory = directoryReader.getDocuments();

frequency = l.frequency(term, "city", directory);
} catch (IOException e) {
e.printStackTrace();
}

channel.sendResponse(new StringRestResponse(RestStatus.OK, String
.valueOf(frequency)));
}
}

Any clue about what can be missing?

Best regards,

Luiz

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Go7dXZAX5SA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Um abraço,

Luiz Henrique Zambom Santana

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Ivan Brusic) #4

The custom action is not required for your REST endpoint to run, but it
ultimately will be required for proper results. Currently only the node
receiving the request will handle the request. If you want ever node to
participate in counting terms, you must send an action via the Client.

As far as your REST endpoint not working, I cannot spot the problem. Are
you running on a multi-node cluster? Does every node have the plugin? Try
removing the superfluous CustomRestRegisterAction constructor. You do not
need to, it just bugs me. :slight_smile:

Cheers,

Ivan

On Thu, Nov 7, 2013 at 1:35 AM, lhzsantana@gmail.com
lhzsantana@gmail.comwrote:

Hi Ivan:

Yes, I did. My plugin class is like this:

public class WordFrequencyPlugin extends AbstractPlugin {

private static Logger log = Logger.getLogger(WordFrequencyPlugin.class);

@Inject
public WordFrequencyPlugin(Settings settings) {
log.info("WordFrequencyPlugin settings");
}

@Inject
public WordFrequencyPlugin() {
}

public String description() {
return "Word frequency counter";
}

public String name() {
return "WordFrequencyPlugin";
}

public void onModule(RestModule module) {
module.addRestAction(CustomRestRegisterAction.class);
log.info("onModule");
}
}

I can see that the onModule method is called and that the handler is
registered (the method "CustomRestRegisterAction" is called). In the Jorg's
plugin I see that he register also an action registerAction (below), that
I do not know if it is necessary to my plugin.

public void onModule(ActionModule module) {
    module.registerAction(TermlistAction.INSTANCE, TransportTermlistAction.class);
}

Can it be what is missing?

Thanks a lot!

2013/11/6 Ivan Brusic ivan@brusic.com

Did you register your action with the RestModule?

Take a look at Jorg's plugin, which might be similar to yours:

https://github.com/jprante/elasticsearch-index-termlist

In his plugin defintion, he adds various actions to various modules:

public void onModule(RestModule module) {

    module.addRestAction(RestTermlistAction.class);

}

https://github.com/jprante/elasticsearch-index-termlist/blob/master/src/main/java/org/xbib/elasticsearch/plugin/termlist/IndexTermlistPlugin.java

Cheers,

Ivan

On Wed, Nov 6, 2013 at 6:57 AM, Luiz Henrique Zambom Santana <
lhzsantana@gmail.com> wrote:

Hello:

I am trying to develop a simple plugin to count terms in a repository
using Lucene and expose the result through a elastic search RestHandler.

I successfully went through these plugins tutorial:

http://www.found.no/foundation/writing-a-plugin/

http://elasticsearchserverbook.com/creating-custom-elasticsearch-rest-action/

And I can see that my plugin is installed and loaded.

[2013-11-06 14:47:00,471][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin]
WordFrequencyPlugin settings
[2013-11-06 14:47:00,472][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] name
[2013-11-06 14:47:00,475][INFO ][plugins ] [Starbolt]
loaded [WordFrequencyPlugin], sites []
[2013-11-06 14:47:00,554][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] onModule
[2013-11-06 14:47:02,200][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.CustomRestRegisterAction]
Registering action /_counter/movies

However, when I try:

lsantana@abc:~/elasticsearch-0.90.6/bin$ curl -XGET
'localhost:9200/_counter/movies?term=XPTO'
No handler found for uri [/_counter/movies?term=XPTO] and method
[GET]lsantana@iqserdev10:~/elasticsearch-0.90.6/bin$

My BaseRestHandler looks like this:

public class CustomRestRegisterAction extends BaseRestHandler {

private static Logger log =
Logger.getLogger(CustomRestRegisterAction.class);
public CustomRestRegisterAction(Settings settings, Client client) {
super(settings, client);
}
@Inject
public CustomRestRegisterAction(Settings settings, Client client,
RestController controller) {
super(settings, client);
String path = "/_counter/movies";
controller.registerHandler(Method.GET, path, new
CustomRestRegisterAction(settings, client));
log.info("Registering action "+path);
}

public void handleRequest(RestRequest request, RestChannel channel) {

log.info("Handling request");
String term = request.param("term");

Lucene l = new Lucene();
int frequency = -1;
try {

DirectoryReader directoryReader = new DirectoryReader();
Directory directory = directoryReader.getDocuments();

frequency = l.frequency(term, "city", directory);
} catch (IOException e) {
e.printStackTrace();
}

channel.sendResponse(new StringRestResponse(RestStatus.OK, String
.valueOf(frequency)));
}
}

Any clue about what can be missing?

Best regards,

Luiz

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Go7dXZAX5SA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
Um abraço,

Luiz Henrique Zambom Santana

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Luiz Henrique Zambom Santana) #5

Hi Ivan:

Thank you a lot for the help.

I started it over again, went to all the steps and now it is working =).

Thanks again!

Luiz

2013/11/7 Ivan Brusic ivan@brusic.com

The custom action is not required for your REST endpoint to run, but it
ultimately will be required for proper results. Currently only the node
receiving the request will handle the request. If you want ever node to
participate in counting terms, you must send an action via the Client.

As far as your REST endpoint not working, I cannot spot the problem. Are
you running on a multi-node cluster? Does every node have the plugin? Try
removing the superfluous CustomRestRegisterAction constructor. You do not
need to, it just bugs me. :slight_smile:

Cheers,

Ivan

On Thu, Nov 7, 2013 at 1:35 AM, lhzsantana@gmail.com <lhzsantana@gmail.com

wrote:

Hi Ivan:

Yes, I did. My plugin class is like this:

public class WordFrequencyPlugin extends AbstractPlugin {

private static Logger log = Logger.getLogger(WordFrequencyPlugin.class);

@Inject
public WordFrequencyPlugin(Settings settings) {
log.info("WordFrequencyPlugin settings");
}

@Inject
public WordFrequencyPlugin() {
}

public String description() {
return "Word frequency counter";
}

public String name() {
return "WordFrequencyPlugin";
}

public void onModule(RestModule module) {
module.addRestAction(CustomRestRegisterAction.class);
log.info("onModule");
}
}

I can see that the onModule method is called and that the handler is
registered (the method "CustomRestRegisterAction" is called). In the Jorg's
plugin I see that he register also an action registerAction (below),
that I do not know if it is necessary to my plugin.

public void onModule(ActionModule module) {

    module.registerAction(TermlistAction.INSTANCE, TransportTermlistAction.class);

}

Can it be what is missing?

Thanks a lot!

2013/11/6 Ivan Brusic ivan@brusic.com

Did you register your action with the RestModule?

Take a look at Jorg's plugin, which might be similar to yours:

https://github.com/jprante/elasticsearch-index-termlist

In his plugin defintion, he adds various actions to various modules:

public void onModule(RestModule module) {


    module.addRestAction(RestTermlistAction.class);


}

https://github.com/jprante/elasticsearch-index-termlist/blob/master/src/main/java/org/xbib/elasticsearch/plugin/termlist/IndexTermlistPlugin.java

Cheers,

Ivan

On Wed, Nov 6, 2013 at 6:57 AM, Luiz Henrique Zambom Santana <
lhzsantana@gmail.com> wrote:

Hello:

I am trying to develop a simple plugin to count terms in a repository
using Lucene and expose the result through a elastic search RestHandler.

I successfully went through these plugins tutorial:

http://www.found.no/foundation/writing-a-plugin/

http://elasticsearchserverbook.com/creating-custom-elasticsearch-rest-action/

And I can see that my plugin is installed and loaded.

[2013-11-06 14:47:00,471][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin]
WordFrequencyPlugin settings
[2013-11-06 14:47:00,472][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] name
[2013-11-06 14:47:00,475][INFO ][plugins ] [Starbolt]
loaded [WordFrequencyPlugin], sites []
[2013-11-06 14:47:00,554][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.WordFrequencyPlugin] onModule
[2013-11-06 14:47:02,200][INFO
][org.elasticsearch.plugin.wordfrequencyplugin.CustomRestRegisterAction]
Registering action /_counter/movies

However, when I try:

lsantana@abc:~/elasticsearch-0.90.6/bin$ curl -XGET
'localhost:9200/_counter/movies?term=XPTO'
No handler found for uri [/_counter/movies?term=XPTO] and method
[GET]lsantana@iqserdev10:~/elasticsearch-0.90.6/bin$

My BaseRestHandler looks like this:

public class CustomRestRegisterAction extends BaseRestHandler {

private static Logger log =
Logger.getLogger(CustomRestRegisterAction.class);
public CustomRestRegisterAction(Settings settings, Client client) {
super(settings, client);
}
@Inject
public CustomRestRegisterAction(Settings settings, Client client,
RestController controller) {
super(settings, client);
String path = "/_counter/movies";
controller.registerHandler(Method.GET, path, new
CustomRestRegisterAction(settings, client));
log.info("Registering action "+path);
}

public void handleRequest(RestRequest request, RestChannel channel) {

log.info("Handling request");
String term = request.param("term");

Lucene l = new Lucene();
int frequency = -1;
try {

DirectoryReader directoryReader = new DirectoryReader();
Directory directory = directoryReader.getDocuments();

frequency = l.frequency(term, "city", directory);
} catch (IOException e) {
e.printStackTrace();
}

channel.sendResponse(new StringRestResponse(RestStatus.OK, String
.valueOf(frequency)));
}
}

Any clue about what can be missing?

Best regards,

Luiz

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Go7dXZAX5SA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
Um abraço,

Luiz Henrique Zambom Santana

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/Go7dXZAX5SA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Um abraço,

Luiz Henrique Zambom Santana

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #6