You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by Apache Wiki <wi...@apache.org> on 2015/02/19 20:01:47 UTC
[Solr Wiki] Update of "FAQ" by TomasFernandezLobbe
Dear Wiki user,
You have subscribed to a wiki page or wiki category on "Solr Wiki" for change notification.
The "FAQ" page has been changed by TomasFernandezLobbe:
https://wiki.apache.org/solr/FAQ?action=diff&rev1=96&rev2=97
There is a wiki page on some brainstorming on how to implement tagging within Solr [UserTagDesign].
== How can I get hold of HttpServletRequest object in custom first-component? ==
+ Set the attribute "addHttpRequestToContext" in the "requestParsers" element to "true" in your solrconfig.xml.
+ Use it in your custom componet like:
- All the request for Solr are served by SolrDispatchFilter. You can extend this filter and override protected execute method to add request object to context in following way
- 1., Create a custom filter class by extending SolrDispatchFilter and override execute method.
- {{{#!java
- package com.custom;
-
- public class CustomSolrDispatchFilter extends SolrDispatchFilter
- {
-
- @Override
- protected void execute( HttpServletRequest req, SolrRequestHandler handler, SolrQueryRequest sreq, SolrQueryResponse rsp) {
-
- sreq.getContext().put("httpRequest", req);
- super.execute(req, handler, sreq, rsp);
-
- }
-
- }
- }}}
- 2., Modify '''web.xml''' to map your filter class instead of SolrDispatchFilter. As custom filter is extended from SolrDispatchFilter everything else apart from execute method gets called from parent.
- {{{
- <filter>
- <filter-name>CustomSolrDispatchFilter</filter-name>
- <filter-class>com.custom.CustomSolrDispatchFilter</filter-class>
- </filter>
- <filter-mapping>
- <filter-name>CustomSolrDispatchFilter</filter-name>
- <url-pattern>/*</url-pattern>
- </filter-mapping>
- }}}
- 3., Rebuild Solr WAR
- 4., Now you can get hold of HttpServletRequest object in your custom first component in following way
{{{#!java
public class CustomSearchComponent extends SearchComponent {
@@ -379, +350 @@
}
}
}}}
+ See https://cwiki.apache.org/confluence/display/solr/RequestDispatcher+in+SolrConfig#RequestDispatcherinSolrConfig-requestParsersElement