[ 
https://issues.apache.org/jira/browse/SOLR-13511?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16858879#comment-16858879
 ] 

Christine Poerschke commented on SOLR-13511:
--------------------------------------------

Thanks [~rwhaddad] for opening this ticket!

So the use case, as you already mentioned, is for Solr plugin authors to be 
able to main per-request state for their plugin in a custom 
[ResponseBuilder|https://github.com/apache/lucene-solr/blob/releases/lucene-solr/8.1.1/solr/core/src/java/org/apache/solr/handler/component/ResponseBuilder.java]
 class.

* code snippets
{code}
package com.mycompany.myteam.solr;

public class CustomSearchHandler extends 
org.apache.solr.handler.component.SearchHandler {
  @Override
  protected ResponseBuilder newResponseBuilder(SolrQueryRequest req, 
SolrQueryResponse rsp, List<SearchComponent> components) {
    return new CustomResponseBuilder(req, rsp, components);
  }
}

public class CustomResponseBuilder extends 
org.apache.solr.handler.component.ResponseBuilder
{
  private FooBar fooBar;

  public void setFooBar(FooBar fooBar) { this.fooBar = fooBar; }
  public FooBar getFooBar() { return this.fooBar; }

  public CustomResponseBuilder(SolrQueryRequest req, SolrQueryResponse rsp, 
List<SearchComponent> components) {
    super(req, rsp, components);
  }
}

public class CustomQueryComponent extends 
org.apache.solr.handler.component.QueryComponent {
  ...
  @Override
  public void process(ResponseBuilder rb) throws IOException {
    super.process(rb);
    if (rb instanceof CustomResponseBuilder) {
      CustomResponseBuilder crb = (CustomResponseBuilder)rb;
      ...
      crb.setFooBar(...);
      ...
    }
  }
  ...
}
{code}

* solrconfig.xml snippet:  
{code}
<searchComponent name="customQuery" 
class="com.mycompany.myteam.solr.CustomQueryComponent"/>

<requestHandler name="/customSelect" 
class="com.mycompany.myteam.solr.CustomSearchHandler">
  <arr name="components">
    <str>customQuery</str>
  </arr>
</requestHandler>
{code}


Latest attached patch includes javadocs for the new method. If there are no 
objections, concerns, questions, etc. then I'll aim to commit the change middle 
of next week or so.

> For SearchHandler, expose "new ResponseBuilder()" to allow override
> -------------------------------------------------------------------
>
>                 Key: SOLR-13511
>                 URL: https://issues.apache.org/jira/browse/SOLR-13511
>             Project: Solr
>          Issue Type: Improvement
>      Security Level: Public(Default Security Level. Issues are Public) 
>          Components: search
>            Reporter: Ramsey Haddad
>            Priority: Trivial
>              Labels: easyfix
>         Attachments: SOLR-13511.patch, SOLR-13511.patch
>
>
> This change is all we want upstream. To use this from our plugins, we intend:
> Extend ResponseBuilder to have additional state (and we think others might 
> want to as well).
> Use an extended SearchHandler that simply creates our ResponseBuilder instead 
> of the standard one.
> We also extend QueryComponent to do our extra behavior if it sees our 
> Response builder instead of the standard one.
> We then change config to use our Search Handler for requestHandler with 
> name="/select" and our QueryComponent for searchComponent with name="query".



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to