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

@ -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

View File

@ -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.

View File

@ -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>

View File

@ -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>

View File

@ -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();

View File

@ -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