mirror of https://github.com/apache/lucene.git
revert dsmiley's other commits: SOLR-2724,SOLR-435,SOLR-3283
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1306331 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a392193e58
commit
0ced8b5020
|
@ -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,
|
||||
|
|
|
@ -39,6 +39,7 @@ public class PingRequestHandler extends RequestHandlerBase
|
|||
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 RequestHandlerBase
|
|||
}
|
||||
|
||||
// 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 ) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.apache.lucene.search.BooleanClause;
|
|||
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 QParser {
|
|||
*/
|
||||
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 QParser {
|
|||
}
|
||||
}
|
||||
|
||||
/** 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 QParser {
|
|||
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 QParser {
|
|||
query.add(phrase, BooleanClause.Occur.SHOULD);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
protected Query getAlternateUserQuery(SolrParams solrParams) throws ParseException {
|
||||
|
@ -197,7 +192,7 @@ public class DisMaxQParser extends QParser {
|
|||
QParser altQParser = subQuery(altQ, null);
|
||||
return altQParser.getQuery();
|
||||
} else {
|
||||
return null;
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing query string");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,7 +172,7 @@ class ExtendedDismaxQParser extends QParser {
|
|||
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 {
|
||||
|
|
|
@ -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 QParserPlugin {
|
|||
}
|
||||
|
||||
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 LuceneQParser {
|
|||
// 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 LuceneQParser {
|
|||
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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -133,7 +133,7 @@ public class SolrQueryParser extends QueryParser {
|
|||
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");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 SolrTestCaseJ4 {
|
|||
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;
|
||||
|
|
|
@ -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. -->
|
||||
|
|
|
@ -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">
|
||||
|
|
Loading…
Reference in New Issue