You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2012/03/28 15:56:20 UTC
svn commit: r1306331 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/handler/
core/src/java/org/apache/solr/schema/ core/src/java/org/apache/solr/search/
core/src/test/org/apache/solr/search/ example/solr/conf/
Author: markrmiller
Date: Wed Mar 28 13:56:19 2012
New Revision: 1306331
URL: http://svn.apache.org/viewvc?rev=1306331&view=rev
Log:
revert dsmiley's other commits: SOLR-2724,SOLR-435,SOLR-3283
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java
lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java
lucene/dev/trunk/solr/example/solr/conf/schema.xml
lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Wed Mar 28 13:56:19 2012
@@ -506,10 +506,6 @@ Upgrading from Solr 3.5
* SOLR-3161: Don't use the 'qt' parameter with a leading '/'. It probably won't work in 4.0
and it's now limited in 3.6 to SearchHandler subclasses that aren't lazy-loaded.
-* SOLR-2724: Specifying <defaultSearchField> and <solrQueryParser defaultOperator="..."/> in
- schema.xml is now considered deprecated. Instead you are encouraged to specify these via the "df"
- and "q.op" parameters in your request handler definition. (David Smiley)
-
New Features
----------------------
* SOLR-2854: Now load URL content stream data (via stream.url) when called for during request handling,
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/handler/PingRequestHandler.java Wed Mar 28 13:56:19 2012
@@ -39,6 +39,7 @@ public class PingRequestHandler extends
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception
{
SolrParams params = req.getParams();
+ SolrParams required = params.required();
SolrCore core = req.getCore();
// Check if the service is available
@@ -48,11 +49,11 @@ public class PingRequestHandler extends
}
// Get the RequestHandler
- String qt = params.get( CommonParams.QT );//optional; you get the default otherwise
+ String qt = required.get( CommonParams.QT );
SolrRequestHandler handler = core.getRequestHandler( qt );
if( handler == null ) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
- "Unknown RequestHandler (qt): "+qt );
+ "Unknown RequestHandler: "+qt );
}
if( handler instanceof PingRequestHandler ) {
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/schema/IndexSchema.java Wed Mar 28 13:56:19 2012
@@ -438,7 +438,7 @@ public final class IndexSchema {
node = (Node) xpath.evaluate("/schema/defaultSearchField/text()", document, XPathConstants.NODE);
if (node==null) {
- log.debug("no default search field specified in schema.");
+ log.warn("no default search field specified in schema.");
} else {
defaultSearchFieldName=node.getNodeValue().trim();
// throw exception if specified, but not found or not indexed
@@ -449,7 +449,7 @@ public final class IndexSchema {
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR, msg );
}
}
- log.info("default search field in schema is "+defaultSearchFieldName);
+ log.info("default search field is "+defaultSearchFieldName);
}
node = (Node) xpath.evaluate("/schema/solrQueryParser/@defaultOperator", document, XPathConstants.NODE);
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java Wed Mar 28 13:56:19 2012
@@ -22,6 +22,7 @@ import org.apache.lucene.search.BooleanC
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.apache.solr.schema.IndexSchema;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.DisMaxParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
@@ -91,9 +92,7 @@ public class DisMaxQParser extends QPars
*/
BooleanQuery query = new BooleanQuery(true);
- boolean notBlank = addMainQuery(query, solrParams);
- if (!notBlank)
- return null;
+ addMainQuery(query, solrParams);
addBoostQuery(query, solrParams);
addBoostFunctions(query, solrParams);
@@ -152,8 +151,7 @@ public class DisMaxQParser extends QPars
}
}
- /** Adds the main query to the query argument. If its blank then false is returned. */
- protected boolean addMainQuery(BooleanQuery query, SolrParams solrParams) throws ParseException {
+ protected void addMainQuery(BooleanQuery query, SolrParams solrParams) throws ParseException {
Map<String, Float> phraseFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.PF));
float tiebreaker = solrParams.getFloat(DisMaxParams.TIE, 0.0f);
@@ -172,8 +170,6 @@ public class DisMaxQParser extends QPars
if (userQuery == null || userQuery.trim().length() < 1) {
// If no query is specified, we may have an alternate
altUserQuery = getAlternateUserQuery(solrParams);
- if (altUserQuery == null)
- return false;
query.add(altUserQuery, BooleanClause.Occur.MUST);
} else {
// There is a valid query string
@@ -188,7 +184,6 @@ public class DisMaxQParser extends QPars
query.add(phrase, BooleanClause.Occur.SHOULD);
}
}
- return true;
}
protected Query getAlternateUserQuery(SolrParams solrParams) throws ParseException {
@@ -197,7 +192,7 @@ public class DisMaxQParser extends QPars
QParser altQParser = subQuery(altQ, null);
return altQParser.getQuery();
} else {
- return null;
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing query string");
}
}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java Wed Mar 28 13:56:19 2012
@@ -172,7 +172,7 @@ class ExtendedDismaxQParser extends QPar
query.add( altUserQuery , BooleanClause.Occur.MUST );
} else {
return null;
- // throw new ParseException("missing query string" );
+ // throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "missing query string" );
}
}
else {
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java Wed Mar 28 13:56:19 2012
@@ -19,6 +19,7 @@ package org.apache.solr.search;
import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
@@ -47,6 +48,7 @@ public class LuceneQParserPlugin extends
}
class LuceneQParser extends QParser {
+ String sortStr;
SolrQueryParser lparser;
public LuceneQParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
@@ -57,7 +59,7 @@ class LuceneQParser extends QParser {
@Override
public Query parse() throws ParseException {
String qstr = getString();
- if (qstr == null || qstr.length()==0) return null;
+ if (qstr == null) return null;
String defaultField = getParam(CommonParams.DF);
if (defaultField==null) {
@@ -93,8 +95,6 @@ class OldLuceneQParser extends LuceneQPa
// handle legacy "query;sort" syntax
if (getLocalParams() == null) {
String qstr = getString();
- if (qstr == null || qstr.length() == 0)
- return null;
sortStr = getParams().get(CommonParams.SORT);
if (sortStr == null) {
// sort may be legacy form, included in the query string
@@ -107,7 +107,7 @@ class OldLuceneQParser extends LuceneQPa
qstr = commands.get(0);
}
else if (commands.size() > 2) {
- throw new ParseException("If you want to use multiple ';' in the query, use the 'sort' param.");
+ throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "If you want to use multiple ';' in the query, use the 'sort' param.");
}
}
setString(qstr);
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java Wed Mar 28 13:56:19 2012
@@ -96,8 +96,7 @@ public abstract class QParser {
lst.add(val);
}
- /** Create and return the <code>Query</code> object represented by <code>qstr</code>. Null MAY be returned to signify
- * there was no input (e.g. no query string) to parse.
+ /** Create and return the <code>Query</code> object represented by <code>qstr</code>
* @see #getQuery()
**/
public abstract Query parse() throws ParseException;
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java Wed Mar 28 13:56:19 2012
@@ -133,7 +133,7 @@ public class SolrQueryParser extends Que
if (field == null && defaultField == null) {
throw new SolrException
(SolrException.ErrorCode.BAD_REQUEST,
- "no field name specified in query and no default specified via 'df' param");
+ "no field name specified in query and no defaultSearchField defined in schema.xml");
}
}
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/QueryParsingTest.java Wed Mar 28 13:56:19 2012
@@ -16,7 +16,6 @@ package org.apache.solr.search;
* limitations under the License.
*/
-import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.apache.lucene.search.SortField;
import org.apache.solr.SolrTestCaseJ4;
@@ -36,40 +35,6 @@ public class QueryParsingTest extends So
initCore("solrconfig.xml","schema.xml");
}
- /**
- * Test that the main QParserPlugins people are likely to use
- * as defaults fail with a consistent exception when the query string
- * is either empty or null.
- * @see <a href="https://issues.apache.org/jira/browse/SOLR-435">SOLR-435</a>
- * @see <a href="https://issues.apache.org/jira/browse/SOLR-2001">SOLR-2001</a>
- */
- public void testQParserEmptyInput() throws Exception {
-
- SolrQueryRequest req = req();
-
- final String[] parsersTested = new String[] {
- OldLuceneQParserPlugin.NAME,
- LuceneQParserPlugin.NAME,
- DisMaxQParserPlugin.NAME,
- ExtendedDismaxQParserPlugin.NAME
- };
-
- for (String defType : parsersTested) {
- for (String qstr : new String[] {null, ""}) {
- QParser parser = null;
- try {
- parser = QParser.getParser(qstr, defType, req);
- } catch (Exception e) {
- throw new RuntimeException("getParser excep using defType=" +
- defType + " with qstr="+qstr, e);
- }
-
- Query q = parser.parse();
- assertNull("expected no query",q);
- }
- }
- }
-
@Test
public void testSort() throws Exception {
Sort sort;
Modified: lucene/dev/trunk/solr/example/solr/conf/schema.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/schema.xml?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/schema.xml (original)
+++ lucene/dev/trunk/solr/example/solr/conf/schema.xml Wed Mar 28 13:56:19 2012
@@ -987,6 +987,12 @@
-->
<uniqueKey>id</uniqueKey>
+ <!-- field for the QueryParser to use when an explicit fieldname is absent -->
+ <defaultSearchField>text</defaultSearchField>
+
+ <!-- SolrQueryParser configuration: defaultOperator="AND|OR" -->
+ <solrQueryParser defaultOperator="OR"/>
+
<!-- copyField commands copy one field to another at the time a document
is added to the index. It's used either to index the same field differently,
or to add multiple fields to the same field for easier/faster searching. -->
Modified: lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml?rev=1306331&r1=1306330&r2=1306331&view=diff
==============================================================================
--- lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml (original)
+++ lucene/dev/trunk/solr/example/solr/conf/solrconfig.xml Wed Mar 28 13:56:19 2012
@@ -734,7 +734,6 @@
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
- <str name="df">text</str>
</lst>
<!-- In addition to defaults, "appends" params can be specified
to identify values which should be appended to the list of
@@ -1041,6 +1040,7 @@
<!-- ping/healthcheck -->
<requestHandler name="/admin/ping" class="solr.PingRequestHandler">
<lst name="invariants">
+ <str name="qt">search</str>
<str name="q">solrpingquery</str>
</lst>
<lst name="defaults">