SOLR-3313 Rename Query Type to Request Handler

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1351932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2012-06-20 04:23:07 +00:00
parent 96d5d8e481
commit f12b94ab86
23 changed files with 49 additions and 33 deletions

View File

@ -265,7 +265,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -219,7 +219,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -69,7 +69,7 @@ public class SolrEntityProcessor extends EntityProcessorBase {
private int rows = ROWS_DEFAULT; private int rows = ROWS_DEFAULT;
private String[] filterQueries; private String[] filterQueries;
private String[] fields; private String[] fields;
private String queryType; private String requestHandler;// 'qt' param
private int timeout = TIMEOUT_SECS; private int timeout = TIMEOUT_SECS;
private boolean initDone = false; private boolean initDone = false;
@ -169,7 +169,7 @@ public class SolrEntityProcessor extends EntityProcessorBase {
if (fieldsAsString != null) { if (fieldsAsString != null) {
this.fields = fieldsAsString.split(","); this.fields = fieldsAsString.split(",");
} }
this.queryType = context.getResolvedEntityAttribute(CommonParams.QT); this.requestHandler = context.getResolvedEntityAttribute(CommonParams.QT);
String timeoutAsString = context.getResolvedEntityAttribute(TIMEOUT); String timeoutAsString = context.getResolvedEntityAttribute(TIMEOUT);
if (timeoutAsString != null) { if (timeoutAsString != null) {
this.timeout = Integer.parseInt(timeoutAsString); this.timeout = Integer.parseInt(timeoutAsString);
@ -183,7 +183,7 @@ public class SolrEntityProcessor extends EntityProcessorBase {
solrQuery.addField(field); solrQuery.addField(field);
} }
} }
solrQuery.setQueryType(queryType); solrQuery.setRequestHandler(requestHandler);
solrQuery.setFilterQueries(filterQueries); solrQuery.setFilterQueries(filterQueries);
solrQuery.setTimeAllowed(timeout * 1000); solrQuery.setTimeAllowed(timeout * 1000);

View File

@ -219,7 +219,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -221,7 +221,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -219,7 +219,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -162,7 +162,7 @@
based HashBitset. --> based HashBitset. -->
<!-- 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' param matching the
name of registered handlers. name of registered handlers.
The "standard" request handler is the default and will be used if qt The "standard" request handler is the default and will be used if qt
is not specified in the request. is not specified in the request.

View File

@ -363,7 +363,7 @@
<!-- <!--
requestHandler plugins... incoming queries will be dispatched to the requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name If no qt is defined, the http://host/app/select?qt=name If no qt is defined, the

View File

@ -363,7 +363,7 @@
<!-- <!--
requestHandler plugins... incoming queries will be dispatched to the requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name If no qt is defined, the http://host/app/select?qt=name If no qt is defined, the

View File

@ -28,10 +28,10 @@ import org.apache.solr.response.SolrQueryResponse;
* One way to register a SolrRequestHandler with the core is thorugh the <code>solrconfig.xml</code> file. * One way to register a SolrRequestHandler with the core is thorugh the <code>solrconfig.xml</code> file.
* <p> * <p>
* Example <code>solrconfig.xml</code> entry to register a <code>SolrRequestHandler</code> implementation to * Example <code>solrconfig.xml</code> entry to register a <code>SolrRequestHandler</code> implementation to
* handle all queries with a query type of "test": * handle all queries with a Request Handler of "/test":
* <p> * <p>
* <code> * <code>
* &lt;requestHandler name="test" class="solr.tst.TestRequestHandler" /&gt; * &lt;requestHandler name="/test" class="solr.tst.TestRequestHandler" /&gt;
* </code> * </code>
* <p> * <p>
* A single instance of any registered SolrRequestHandler is created * A single instance of any registered SolrRequestHandler is created

View File

@ -234,7 +234,7 @@ public class SolrDispatchFilter implements Filter
if( qt != null && qt.startsWith("/") && (handler instanceof ContentStreamHandlerBase)) { if( qt != null && qt.startsWith("/") && (handler instanceof ContentStreamHandlerBase)) {
//For security reasons it's a bad idea to allow a leading '/', ex: /select?qt=/update see SOLR-3161 //For security reasons it's a bad idea to allow a leading '/', ex: /select?qt=/update see SOLR-3161
//There was no restriction from Solr 1.4 thru 3.5 and it's not supported for update handlers. //There was no restriction from Solr 1.4 thru 3.5 and it's not supported for update handlers.
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Invalid query type. Do not use /select to access: "+qt); throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "Invalid Request Handler ('qt'). Do not use /select to access: "+qt);
} }
} }
} }

View File

@ -195,7 +195,7 @@
based HashBitset. --> based HashBitset. -->
<!-- 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' param matching the
name of registered handlers. name of registered handlers.
The "standard" request handler is the default and will be used if qt The "standard" request handler is the default and will be used if qt
is not specified in the request. is not specified in the request.

View File

@ -258,7 +258,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -283,7 +283,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -258,7 +258,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -258,7 +258,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -222,7 +222,7 @@
<!-- requestHandler plugins... incoming queries will be dispatched to the <!-- requestHandler plugins... incoming queries will be dispatched to the
correct handler based on the path or the qt (query type) param. correct handler based on the path or the 'qt' param.
Names starting with a '/' are accessed with the a path equal to the Names starting with a '/' are accessed with the a path equal to the
registered name. Names without a leading '/' are accessed with: registered name. Names without a leading '/' are accessed with:
http://host/app/select?qt=name http://host/app/select?qt=name

View File

@ -17,7 +17,6 @@
package org.apache.solr.client.solrj; package org.apache.solr.client.solrj;
import org.apache.solr.client.solrj.util.ClientUtils;
import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.FacetParams; import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.HighlightParams; import org.apache.solr.common.params.HighlightParams;
@ -26,7 +25,6 @@ import org.apache.solr.common.params.StatsParams;
import org.apache.solr.common.params.TermsParams; import org.apache.solr.common.params.TermsParams;
import org.apache.solr.common.util.DateUtil; import org.apache.solr.common.util.DateUtil;
import java.text.NumberFormat;
import java.util.Date; import java.util.Date;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -709,21 +707,39 @@ public class SolrQuery extends ModifiableSolrParams
} }
/** /**
* Query type used to determine the request handler. * The Request Handler to use (see the solrconfig.xml), which is stored in the "qt" parameter.
* @see org.apache.solr.client.solrj.request.QueryRequest#getPath() * Normally it starts with a '/' and if so it will be used by
* * {@link org.apache.solr.client.solrj.request.QueryRequest#getPath()} in the URL instead of the "qt" parameter.
* @param qt Query Type that corresponds to the query request handler on the server. * If this is left blank, then the default of "/select" is assumed.
*
* @param qt The Request Handler name corresponding to one in solrconfig.xml on the server.
* @return this * @return this
*/ */
public SolrQuery setQueryType(String qt) { public SolrQuery setRequestHandler(String qt) {
this.set(CommonParams.QT, qt); this.set(CommonParams.QT, qt);
return this; return this;
} }
public String getQueryType() { public String getRequestHandler() {
return this.get(CommonParams.QT); return this.get(CommonParams.QT);
} }
/**
* @deprecated See {@link #setRequestHandler(String)}.
*/
@Deprecated
public SolrQuery setQueryType(String qt) {
return setRequestHandler(qt);
}
/**
* @deprecated See {@link #getRequestHandler()}.
*/
@Deprecated
public String getQueryType() {
return getRequestHandler();
}
/** /**
* @see ModifiableSolrParams#set(String,String[]) * @see ModifiableSolrParams#set(String,String[])
* @param name * @param name

View File

@ -39,7 +39,7 @@ public interface CommonParams {
*/ */
public static final String TZ = "TZ"; public static final String TZ = "TZ";
/** the query type - which query handler should handle the request */ /** the Request Handler (formerly known as the Query Type) - which Request Handler should handle the request */
public static final String QT ="qt"; public static final String QT ="qt";
/** the response writer type - the format of the response */ /** the response writer type - the format of the response */

View File

@ -37,7 +37,7 @@ public interface ShardParams {
/** The requested URL for this shard */ /** The requested URL for this shard */
public static final String SHARD_URL = "shard.url"; public static final String SHARD_URL = "shard.url";
/** query type for shard requests */ /** The Request Handler for shard requests */
public static final String SHARDS_QT = "shards.qt"; public static final String SHARDS_QT = "shards.qt";
/** Request detailed match info for each shard (true/false) */ /** Request detailed match info for each shard (true/false) */

View File

@ -203,7 +203,7 @@ public abstract class MultiCoreExampleTestBase extends SolrExampleTestBase
catch( Exception ex ) {} catch( Exception ex ) {}
assertEquals( 1, getSolrCore("corefoo").query( new SolrQuery( "id:BBB" ) ).getResults().size() ); assertEquals( 1, getSolrCore("corefoo").query( new SolrQuery( "id:BBB" ) ).getResults().size() );
NamedList<Object> response = getSolrCore("corefoo").query(new SolrQuery().setQueryType("/admin/system")).getResponse(); NamedList<Object> response = getSolrCore("corefoo").query(new SolrQuery().setRequestHandler("/admin/system")).getResponse();
NamedList<Object> coreInfo = (NamedList<Object>) response.get("core"); NamedList<Object> coreInfo = (NamedList<Object>) response.get("core");
String indexDir = (String) ((NamedList<Object>) coreInfo.get("directory")).get("index"); String indexDir = (String) ((NamedList<Object>) coreInfo.get("directory")).get("index");
// test delete index on core // test delete index on core

View File

@ -166,7 +166,7 @@ public class SolrQueryTest extends LuceneTestCase {
assertEquals("foo", q.setQuery("foo").getQuery()); assertEquals("foo", q.setQuery("foo").getQuery());
assertEquals(10, q.setRows(10).getRows().intValue()); assertEquals(10, q.setRows(10).getRows().intValue());
assertEquals(10, q.setStart(10).getStart().intValue()); assertEquals(10, q.setStart(10).getStart().intValue());
assertEquals("foo", q.setQueryType("foo").getQueryType()); assertEquals("foo", q.setRequestHandler("foo").getRequestHandler());
assertEquals(10, q.setTimeAllowed(10).getTimeAllowed().intValue()); assertEquals(10, q.setTimeAllowed(10).getTimeAllowed().intValue());
// non-standard // non-standard

View File

@ -57,7 +57,7 @@ public class TermsResponseTest extends SolrJettyTestBase {
getSolrServer().commit(true, true); getSolrServer().commit(true, true);
SolrQuery query = new SolrQuery(); SolrQuery query = new SolrQuery();
query.setQueryType("/terms"); query.setRequestHandler("/terms");
query.setTerms(true); query.setTerms(true);
query.setTermsLimit(5); query.setTermsLimit(5);
query.setTermsLower("s"); query.setTermsLower("s");