mirror of https://github.com/apache/lucene.git
SOLR-8284: fix NPE short form sort:index and sort:count
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1714641 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
efa69bb18e
commit
0186803a9d
|
@ -391,6 +391,10 @@ Bug Fixes
|
|||
* SOLR-8287: TrieDoubleField and TrieLongField now override toNativeType
|
||||
(Ishan Chattopadhyaya via Christine Poerschke)
|
||||
|
||||
* SOLR-8284: JSON Facet API - fix NPEs when short form "sort:index" or "sort:count"
|
||||
are used. (Michael Sun via yonik)
|
||||
|
||||
|
||||
Optimizations
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -563,6 +563,7 @@ class FacetFieldParser extends FacetParser<FacetField> {
|
|||
facet.sortVariable = sortStr.substring(0, sortStr.length()-" desc".length());
|
||||
facet.sortDirection = FacetField.SortDirection.desc;
|
||||
} else {
|
||||
facet.sortVariable = sortStr;
|
||||
facet.sortDirection = "index".equals(facet.sortVariable) ? FacetField.SortDirection.asc : FacetField.SortDirection.desc; // default direction for "index" is ascending
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -542,6 +542,22 @@ public class TestJsonFacets extends SolrTestCaseHS {
|
|||
"}"
|
||||
);
|
||||
|
||||
// test sorting by default count/index order
|
||||
client.testJQ(params(p, "q", "*:*"
|
||||
, "json.facet", "{f1:{terms:{${terms} field:'${cat_s}', sort:'count' } }" +
|
||||
" , f2:{terms:{${terms} field:'${cat_s}', sort:'count asc' } }" +
|
||||
" , f3:{terms:{${terms} field:'${cat_s}', sort:'index' } }" +
|
||||
" , f4:{terms:{${terms} field:'${cat_s}', sort:'index desc' } }" +
|
||||
"}"
|
||||
)
|
||||
, "facets=={ count:6 " +
|
||||
" ,f1:{buckets:[ {val:B,count:3}, {val:A,count:2} ] }" +
|
||||
" ,f2:{buckets:[ {val:A,count:2}, {val:B,count:3} ] }" +
|
||||
" ,f3:{buckets:[ {val:A,count:2}, {val:B,count:3} ] }" +
|
||||
" ,f4:{buckets:[ {val:B,count:3}, {val:A,count:2} ] }" +
|
||||
"}"
|
||||
);
|
||||
|
||||
|
||||
// test tiebreaks when sorting by count
|
||||
client.testJQ(params(p, "q", "id:1 id:6"
|
||||
|
|
Loading…
Reference in New Issue