mirror of https://github.com/apache/lucene.git
SOLR-1138: gracefully handle empty and null queries
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@771268 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5383ab17b3
commit
44302daeb2
|
@ -354,6 +354,7 @@ Bug Fixes
|
|||
|
||||
41. SOLR-1135: Java replication creates Snapshot in the directory where Solr was launched (Jianhan Guo via shalin)
|
||||
|
||||
42. SOLR-1138: Query Elevation Component now gracefully handles missing queries. (gsingers)
|
||||
|
||||
Other Changes
|
||||
----------------------
|
||||
|
|
|
@ -52,6 +52,7 @@ import org.apache.lucene.search.Sort;
|
|||
import org.apache.lucene.search.SortComparatorSource;
|
||||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.MatchAllDocsQuery;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.DOMUtil;
|
||||
|
@ -324,12 +325,12 @@ public class QueryElevationComponent extends SearchComponent implements SolrCore
|
|||
boolean force = params.getBool( FORCE_ELEVATION, forceElevation );
|
||||
|
||||
Query query = rb.getQuery();
|
||||
if( query == null ) {
|
||||
throw new SolrException( SolrException.ErrorCode.SERVER_ERROR,
|
||||
"The QueryElevationComponent needs to be registered 'after' the query component" );
|
||||
String qstr = rb.getQueryString();
|
||||
if( query == null || qstr == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String qstr = getAnalyzedQuery( rb.getQueryString() );
|
||||
qstr = getAnalyzedQuery(qstr);
|
||||
IndexReader reader = req.getSearcher().getReader();
|
||||
ElevationObj booster = null;
|
||||
try {
|
||||
|
|
|
@ -86,6 +86,23 @@ public class QueryElevationComponentTest extends AbstractSolrTestCase {
|
|||
assertEquals( "xxxxyyyy", comp.getAnalyzedQuery( "XXXX YYYY" ) );
|
||||
}
|
||||
|
||||
public void testEmptyQuery() throws Exception {
|
||||
SolrCore core = h.getCore();
|
||||
|
||||
|
||||
|
||||
//String query = "title:ipod";
|
||||
|
||||
Map<String,String> args = new HashMap<String, String>();
|
||||
args.put( "q.alt", "*:*" );
|
||||
args.put( "defType", "dismax");
|
||||
//args.put( CommonParams.FL, "id,title,score" );
|
||||
SolrQueryRequest req = new LocalSolrQueryRequest( core, new MapSolrParams( args) );
|
||||
assertQ("Make sure QEC handles null queries", req, "//*[@numFound='0']");
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void testSorting() throws IOException
|
||||
{
|
||||
SolrCore core = h.getCore();
|
||||
|
|
Loading…
Reference in New Issue