You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Noble Paul (Jira)" <ji...@apache.org> on 2020/07/11 00:15:00 UTC

[jira] [Resolved] (SOLR-14404) CoreContainer level custom requesthandlers

     [ https://issues.apache.org/jira/browse/SOLR-14404?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Noble Paul resolved SOLR-14404.
-------------------------------
    Fix Version/s: 8.6
       Resolution: Fixed

> CoreContainer level custom requesthandlers
> ------------------------------------------
>
>                 Key: SOLR-14404
>                 URL: https://issues.apache.org/jira/browse/SOLR-14404
>             Project: Solr
>          Issue Type: New Feature
>          Components: packages
>            Reporter: Noble Paul
>            Assignee: Noble Paul
>            Priority: Major
>             Fix For: 8.6
>
>          Time Spent: 5.5h
>  Remaining Estimate: 0h
>
> caveats:
>  * The class should be annotated with  {{org.apache.solr.api.EndPoint}}. Which means only V2 APIs are supported
>  * The path should have prefix {{/api/plugin}}
> add a plugin
> {code:java}
> curl -X POST -H 'Content-type:application/json' --data-binary '
> {
>   "add": {
>   "name":"myplugin",
>   "class": "full.ClassName", 
>   "path-prefix" : "some-path-prefix"    
>   }
> }' http://localhost:8983/api/cluster/plugins
> {code}
> add a plugin from a package
> {code:java}
> curl -X POST -H 'Content-type:application/json' --data-binary '
> {
>   "add": {
>   "name":"myplugin", 
>   "class": "pkgName:full.ClassName" ,
>   "path-prefix" : "some-path-prefix"  ,  
>   "version: "1.0"   
>   }
> }' http://localhost:8983/api/cluster/plugins
> {code}
> remove a plugin
> {code:java}
> curl -X POST -H 'Content-type:application/json' --data-binary '
> {
>   "remove": "myplugin"
> }' http://localhost:8983/api/cluster/plugins
> {code}
> The configuration will be stored in the {{clusterprops.json}}
>  as
> {code:java}
> {
> "plugins" : {
> "myplugin" : {"class": "full.ClassName", "path-prefix" : "some-path-prefix" }
> }
> }
> {code}
> example plugin
> {code:java}
> public class MyPlugin {
>   private final CoreContainer coreContainer;
>   public MyPlugin(CoreContainer coreContainer) {
>     this.coreContainer = coreContainer;
>   }
>   @EndPoint(path = "/$path-prefix/path1",
>     method = METHOD.GET,
>     permission = READ)
>   public void call(SolrQueryRequest req, SolrQueryResponse rsp){
>     rsp.add("myplugin.version", "2.0");
>   }
> }
> {code}
> This plugin will be accessible on all nodes at {{/api/some-path-prefix/path1}}. It's possible to add more methods at different paths. Ensure that all paths start with {{$path-prefix}} because that is the prefix in which the plugin is registered with. So {{/some-path-prefix/path2}} , {{/some-path-prefix/my/deeply/nested/path}} are all valid paths. 
> It's possible that the user chooses to register the plugin with a different name. In that case , use a template variable as follows in paths {{/cluster/some/other/path}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org