SOLR-204: Make it possible for the request dispatcher to handle /select. This offers uniform error handling for /update and /select.

This change will affect anyone who has added "enableRemoteStreaming" to their solrconfig.xml since solr1.1

Where you had:
<requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" /> 

You now need:
<requestDispatcher handleSelect="true" >
  <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
</requestDispatcher>



git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@533558 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2007-04-29 20:47:23 +00:00
parent 53dc0b4317
commit 25a185b7da
6 changed files with 33 additions and 27 deletions

View File

@ -152,6 +152,12 @@ New Features
solr using the standard request/response formats, but does not require solr using the standard request/response formats, but does not require
an HTTP connection. It is designed for embedded applications. (ryan) an HTTP connection. It is designed for embedded applications. (ryan)
25. SOLR-204: The request dispatcher (added in SOLR-104) can handle
calls to /select. This offers uniform error handling for /update and
/select. To enable this behavior, you must add:
<requestDispatcher handleSelect="true" > to your solrconfig.xml
See the example solrconfig.xml for details. (ryan)
Changes in runtime behavior Changes in runtime behavior
1. Highlighting using DisMax will only pick up terms from the main 1. Highlighting using DisMax will only pick up terms from the main
user query, not boost or filter queries (klaas). user query, not boost or filter queries (klaas).

View File

@ -231,8 +231,16 @@
</query> </query>
<!--
Let the dispatch filter handler /select?qt=XXX
handleSelect=true will use consistent error handling for /select and /update
handleSelect=false will use solr1.1 style error formatting
-->
<requestDispatcher handleSelect="true" >
<!--Make sure your system has some authentication before enabling remote streaming! --> <!--Make sure your system has some authentication before enabling remote streaming! -->
<requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" /> <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
</requestDispatcher>
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the qt (query type) param matching the correct handler based on the qt (query type) param matching the

View File

@ -267,7 +267,9 @@
</requestHandler> </requestHandler>
<!-- enable streaming for testing... --> <!-- enable streaming for testing... -->
<requestDispatcher handleSelect="true" >
<requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" /> <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
</requestDispatcher>
<admin> <admin>
<defaultQuery>solr</defaultQuery> <defaultQuery>solr</defaultQuery>

View File

@ -35,10 +35,6 @@
<filter-name>SolrRequestFilter</filter-name> <filter-name>SolrRequestFilter</filter-name>
<filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class> <filter-class>org.apache.solr.servlet.SolrDispatchFilter</filter-class>
<!-- <!--
<init-param>
<param-name>handle-select</param-name>
<param-value>true</param-value>
</init-param>
<init-param> <init-param>
<param-name>path-prefix</param-name> <param-name>path-prefix</param-name>
<param-value>/xxx</param-value> <param-value>/xxx</param-value>

View File

@ -60,7 +60,10 @@ public class SolrDispatchFilter implements Filter
try { try {
// web.xml configuration // web.xml configuration
this.pathPrefix = config.getInitParameter( "path-prefix" ); this.pathPrefix = config.getInitParameter( "path-prefix" );
this.handleSelect = "true".equals( config.getInitParameter( "handle-select" ) );
// Let this filter take care of /select?xxx format
this.handleSelect =
SolrConfig.config.getBool( "requestDispatcher/@handleSelect", false );
log.info("user.dir=" + System.getProperty("user.dir")); log.info("user.dir=" + System.getProperty("user.dir"));
core = SolrCore.getSolrCore(); core = SolrCore.getSolrCore();

View File

@ -32,12 +32,12 @@ import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.xml.xpath.XPathConstants;
import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.solr.core.Config; import org.apache.solr.core.Config;
import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrException; import org.apache.solr.core.SolrException;
import org.apache.solr.util.ContentStream; import org.apache.solr.util.ContentStream;
@ -47,9 +47,6 @@ import org.apache.solr.request.SolrParams;
import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.request.SolrQueryRequestBase;
import org.apache.solr.util.ContentStreamBase; import org.apache.solr.util.ContentStreamBase;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class SolrRequestParsers public class SolrRequestParsers
@ -71,20 +68,12 @@ public class SolrRequestParsers
{ {
this.core = core; this.core = core;
long uploadLimitKB = 2000; // 2MB default // Read the configuration
NodeList nodes = (NodeList)config.evaluate("requestParsers", XPathConstants.NODESET); long uploadLimitKB = SolrConfig.config.getInt(
if( nodes!=null && nodes.getLength()>0 ) { "requestDispatcher/requestParsers/@multipartUploadLimitInKB", 2000 ); // 2MB default
// only look at the first node.
NamedNodeMap attrs = nodes.item(0).getAttributes(); this.enableRemoteStreams = SolrConfig.config.getBool(
Node node = attrs.getNamedItem( "enableRemoteStreaming" ); "requestDispatcher/requestParsers/@enableRemoteStreaming", false );
if( node != null ) {
enableRemoteStreams = Boolean.parseBoolean( node.getTextContent() );
}
node = attrs.getNamedItem( "multipartUploadLimitInKB" );
if( node != null ) {
uploadLimitKB = Long.parseLong( node.getTextContent() );
}
}
MultipartRequestParser multi = new MultipartRequestParser( uploadLimitKB ); MultipartRequestParser multi = new MultipartRequestParser( uploadLimitKB );
RawRequestParser raw = new RawRequestParser(); RawRequestParser raw = new RawRequestParser();
@ -394,3 +383,5 @@ class StandardRequestParser implements SolrRequestParser