mirror of https://github.com/apache/lucene.git
SOLR-14189 switch from String.trim() to StringUtils.isBlank() (#1172)
This commit is contained in:
parent
0635756f76
commit
efd0e8f3e8
|
@ -33,6 +33,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Query parser for dismax queries
|
||||
* <p>
|
||||
|
@ -193,7 +195,7 @@ public class DisMaxQParser extends QParser {
|
|||
parsedUserQuery = null;
|
||||
String userQuery = getString();
|
||||
altUserQuery = null;
|
||||
if (userQuery == null || userQuery.trim().length() < 1) {
|
||||
if (StringUtils.isBlank(userQuery)) {
|
||||
// If no query is specified, we may have an alternate
|
||||
altUserQuery = getAlternateUserQuery(solrParams);
|
||||
if (altUserQuery == null)
|
||||
|
|
|
@ -29,6 +29,8 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.analysis.core.StopFilterFactory;
|
||||
import org.apache.lucene.analysis.util.TokenFilterFactory;
|
||||
|
@ -132,7 +134,7 @@ public class ExtendedDismaxQParser extends QParser {
|
|||
parsedUserQuery = null;
|
||||
String userQuery = getString();
|
||||
altUserQuery = null;
|
||||
if( userQuery == null || userQuery.trim().length() == 0 ) {
|
||||
if (StringUtils.isBlank(userQuery)) {
|
||||
// If no query is specified, we may have an alternate
|
||||
if (config.altQ != null) {
|
||||
QParser altQParser = subQuery(config.altQ, null);
|
||||
|
|
|
@ -25,6 +25,8 @@ import org.apache.solr.common.SolrException;
|
|||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.request.SolrQueryRequest;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/*
|
||||
*
|
||||
* Syntax: q=*:*&rq={!rerank reRankQuery=$rqq reRankDocs=300 reRankWeight=3}
|
||||
|
@ -56,7 +58,7 @@ public class ReRankQParserPlugin extends QParserPlugin {
|
|||
|
||||
public Query parse() throws SyntaxError {
|
||||
String reRankQueryString = localParams.get(RERANK_QUERY);
|
||||
if (reRankQueryString == null || reRankQueryString.trim().length() == 0) {
|
||||
if (StringUtils.isBlank(reRankQueryString)) {
|
||||
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, RERANK_QUERY+" parameter is mandatory");
|
||||
}
|
||||
QParser reRankParser = QParser.getParser(reRankQueryString, req);
|
||||
|
|
|
@ -242,6 +242,12 @@ public class TestExtendedDismaxParser extends SolrTestCaseJ4 {
|
|||
"defType","edismax")
|
||||
,allr);
|
||||
|
||||
assertQ("ideographic space should be considered whitespace",
|
||||
req("q","\u3000",
|
||||
"q.alt",allq,
|
||||
"defType","edismax")
|
||||
,allr);
|
||||
|
||||
assertQ("expected doc is missing (using un-escaped edismax w/qf)",
|
||||
req("q", "literal:colon",
|
||||
"qf", "t_special",
|
||||
|
|
Loading…
Reference in New Issue