Skip to content

Apache Lucene open-source search software

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

Ryan McKinley25a185b7da92
diff --git a/CHANGES.txt b/CHANGES.txt
index b18f5d40859..5b58ab24cff 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -151,6 +151,12 @@ New Features
24. SOLR-212: Added a DirectSolrConnection class. This lets you access
solr using the standard request/response formats, but does not require
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
1. Highlighting using DisMax will only pick up terms from the main
diff --git a/example/solr/conf/solrconfig.xml b/example/solr/conf/solrconfig.xml
index c5eeb4f90da..1c78a66370f 100755
--- a/example/solr/conf/solrconfig.xml
+++ b/example/solr/conf/solrconfig.xml
@@ -231,9 +231,17 @@
</query>
- <!--Make sure your system has some authentication before enabling remote streaming! -->
- <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
-
+ <!--
+ 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! -->
+ <requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
+ </requestDispatcher>
+
+
<!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the qt (query type) param matching the
name of registered handlers.
diff --git a/src/test/test-files/solr/conf/solrconfig.xml b/src/test/test-files/solr/conf/solrconfig.xml
index 0084d668524..000d8b434c4 100644
--- a/src/test/test-files/solr/conf/solrconfig.xml
+++ b/src/test/test-files/solr/conf/solrconfig.xml
@@ -267,7 +267,9 @@
</requestHandler>
<!-- enable streaming for testing... -->
- <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
+ <requestDispatcher handleSelect="true" >
+ <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048" />
+ </requestDispatcher>
<admin>
<defaultQuery>solr</defaultQuery>
diff --git a/src/webapp/WEB-INF/web.xml b/src/webapp/WEB-INF/web.xml
index ffaa8ebcec6..ecf38e23463 100644
--- a/src/webapp/WEB-INF/web.xml
+++ b/src/webapp/WEB-INF/web.xml
@@ -35,10 +35,6 @@
<filter-name>SolrRequestFilter</filter-name>
<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>
<param-name>path-prefix</param-name>
<param-value>/xxx</param-value>
diff --git a/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java b/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java
index 77574f9c46c..aeb07ed750d 100644
--- a/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/src/webapp/src/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -60,7 +60,10 @@ public class SolrDispatchFilter implements Filter
try {
// web.xml configuration
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"));
core = SolrCore.getSolrCore();
diff --git a/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java b/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java
index 0399f299731..6f1995b2d41 100644
--- a/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java
+++ b/src/webapp/src/org/apache/solr/servlet/SolrRequestParsers.java
@@ -32,12 +32,12 @@ import java.util.Map;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletRequest;
-import javax.xml.xpath.XPathConstants;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.solr.core.Config;
+import org.apache.solr.core.SolrConfig;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrException;
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.SolrQueryRequestBase;
import org.apache.solr.util.ContentStreamBase;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
public class SolrRequestParsers
@@ -71,21 +68,13 @@ public class SolrRequestParsers
{
this.core = core;
- long uploadLimitKB = 2000; // 2MB default
- NodeList nodes = (NodeList)config.evaluate("requestParsers", XPathConstants.NODESET);
- if( nodes!=null && nodes.getLength()>0 ) {
- // only look at the first node.
- NamedNodeMap attrs = nodes.item(0).getAttributes();
- Node node = attrs.getNamedItem( "enableRemoteStreaming" );
- if( node != null ) {
- enableRemoteStreams = Boolean.parseBoolean( node.getTextContent() );
- }
- node = attrs.getNamedItem( "multipartUploadLimitInKB" );
- if( node != null ) {
- uploadLimitKB = Long.parseLong( node.getTextContent() );
- }
- }
+ // Read the configuration
+ long uploadLimitKB = SolrConfig.config.getInt(
+ "requestDispatcher/requestParsers/@multipartUploadLimitInKB", 2000 ); // 2MB default
+ this.enableRemoteStreams = SolrConfig.config.getBool(
+ "requestDispatcher/requestParsers/@enableRemoteStreaming", false );
+
MultipartRequestParser multi = new MultipartRequestParser( uploadLimitKB );
RawRequestParser raw = new RawRequestParser();
standard = new StandardRequestParser( multi, raw );
@@ -394,3 +383,5 @@ class StandardRequestParser implements SolrRequestParser
+
+