SOLR-13227: don't throw exceptions for counting facet.range.other.

This commit is contained in:
Mikhail Khludnev 2019-02-26 23:38:28 +03:00
parent 8f78c0591c
commit 58beaeb74d
2 changed files with 23 additions and 27 deletions

View File

@ -86,6 +86,8 @@ Improvements
* SOLR-12121: JWT Token authentication plugin with OpenID Connect implicit flow login through Admin UI (janhoy)
* SOLR-13227: Optimizing facet.range.other by avoiding expensive exceptions (Nikolay Khitrin via Mikhail Khludnev)
Other Changes
----------------------

View File

@ -178,35 +178,29 @@ public class RangeFacetProcessor extends SimpleFacets {
IntervalFacets.FacetInterval after = null;
for (RangeFacetRequest.FacetRange range : rfr.getFacetRanges()) {
try {
FacetRangeOther other = FacetRangeOther.get(range.name);
if (other != null) {
switch (other) {
case BEFORE:
assert range.lower == null;
intervals.set(0, new IntervalFacets.FacetInterval(sf, "*", range.upper, range.includeLower,
range.includeUpper, FacetRangeOther.BEFORE.toString()));
break;
case AFTER:
assert range.upper == null;
after = new IntervalFacets.FacetInterval(sf, range.lower, "*",
range.includeLower, range.includeUpper, FacetRangeOther.AFTER.toString());
break;
case BETWEEN:
intervals.set(includeBefore ? 1 : 0, new IntervalFacets.FacetInterval(sf, range.lower, range.upper,
range.includeLower, range.includeUpper, FacetRangeOther.BETWEEN.toString()));
break;
case ALL:
case NONE:
break;
}
if (range.other != null) {
switch (range.other) {
case BEFORE:
assert range.lower == null;
intervals.set(0, new IntervalFacets.FacetInterval(sf, "*", range.upper, range.includeLower,
range.includeUpper, FacetRangeOther.BEFORE.toString()));
break;
case AFTER:
assert range.upper == null;
after = new IntervalFacets.FacetInterval(sf, range.lower, "*",
range.includeLower, range.includeUpper, FacetRangeOther.AFTER.toString());
break;
case BETWEEN:
intervals.set(includeBefore ? 1 : 0, new IntervalFacets.FacetInterval(sf, range.lower, range.upper,
range.includeLower, range.includeUpper, FacetRangeOther.BETWEEN.toString()));
break;
case ALL:
case NONE:
break;
}
continue;
} catch (SolrException e) {
// safe to ignore
} else {
intervals.add(new IntervalFacets.FacetInterval(sf, range.lower, range.upper, range.includeLower, range.includeUpper, range.lower));
}
intervals.add(new IntervalFacets.FacetInterval(sf, range.lower, range.upper, range.includeLower, range.includeUpper, range.lower));
}
if (includeAfter) {