SOLR-5034: A facet.query that parses or analyzes down to a null Query would throw a NPE.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1502730 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Wayne Smiley 2013-07-13 00:05:10 +00:00
parent 792bae8b26
commit d2a2cc12dc
3 changed files with 13 additions and 1 deletions

View File

@ -307,6 +307,9 @@ Bug Fixes
switching shard states. Multiple bugs related to sub shard recovery and switching shard states. Multiple bugs related to sub shard recovery and
replication are also fixed. (shalin) replication are also fixed. (shalin)
* SOLR-5034: A facet.query that parses or analyzes down to a null Query would
throw a NPE. Fixed. (David Smiley)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -295,7 +295,9 @@ public class SimpleFacets {
// TODO: slight optimization would prevent double-parsing of any localParams // TODO: slight optimization would prevent double-parsing of any localParams
Query qobj = QParser.getParser(q, null, req).getQuery(); Query qobj = QParser.getParser(q, null, req).getQuery();
if (params.getBool(GroupParams.GROUP_FACET, false)) { if (qobj == null) {
res.add(key, 0);
} else if (params.getBool(GroupParams.GROUP_FACET, false)) {
res.add(key, getGroupedFacetQueryCount(qobj)); res.add(key, getGroupedFacetQueryCount(qobj));
} else { } else {
res.add(key, searcher.numDocs(qobj, docs)); res.add(key, searcher.numDocs(qobj, docs));

View File

@ -621,6 +621,13 @@ public class SimpleFacetsTest extends SolrTestCaseJ4 {
) )
,"*[count(//lst[@name='zerolen_s']/int)=1]" ,"*[count(//lst[@name='zerolen_s']/int)=1]"
); );
assertQ("a facet.query that analyzes to no query shoud not NPE",
req("q", "*:*",
"facet", "true",
"facet.query", "{!field key=k f=lengthfilt}a"),//2 char minimum
"//lst[@name='facet_queries']/int[@name='k'][.='0']"
);
} }
public static void indexDateFacets() { public static void indexDateFacets() {