SOLR-2682: remove addException() from SimpleFacet

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1152456 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Koji Sekiguchi 2011-07-30 11:35:55 +00:00
parent 149d3de96d
commit 13347bd3bc
2 changed files with 25 additions and 54 deletions

View File

@ -53,6 +53,8 @@ Upgrading from Solr 3.3-dev
legacy behavior should set a default value for the 'mm' param in
their solrconfig.xml file.
* FacetComponent no longer catches and embeds exceptions occurred during facet
processing, it throws HTTP 400 or 500 exceptions instead.
Detailed Change List
----------------------
@ -213,6 +215,9 @@ Bug Fixes
* SOLR-2193, SOLR-2565, SOLR-2651: SolrCores now properly share IndexWriters across SolrCore reloads.
(Mark Miller, Robert Muir)
* SOLR-2682: Remove addException() in SimpleFacet. FacetComponent no longer catches and embeds
exceptions occurred during facet processing, it throws HTTP 400 or 500 exceptions instead. (koji)
Other Changes
----------------------

View File

@ -28,6 +28,7 @@ import org.apache.lucene.util.packed.Direct32;
import org.apache.lucene.util.packed.Direct8;
import org.apache.lucene.util.packed.PackedInts;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrException.ErrorCode;
import org.apache.solr.common.params.FacetParams;
import org.apache.solr.common.params.RequiredSolrParams;
import org.apache.solr.common.params.SolrParams;
@ -191,26 +192,16 @@ public class SimpleFacets {
facetResponse.add("facet_dates", getFacetDateCounts());
facetResponse.add("facet_ranges", getFacetRangeCounts());
} catch (Exception e) {
} catch (IOException e) {
SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);
addException("Exception during facet counts", e);
throw new SolrException(ErrorCode.SERVER_ERROR, e);
} catch (ParseException e) {
SolrException.logOnce(SolrCore.log, "Exception during facet counts", e);
throw new SolrException(ErrorCode.BAD_REQUEST, e);
}
return facetResponse;
}
public void addException(String msg, Exception e) {
@SuppressWarnings("unchecked")
List<String> exceptions = (List<String>)facetResponse.get("exception");
if (exceptions == null) {
exceptions = new ArrayList<String>();
facetResponse.add("exception", exceptions);
}
String entry = msg + '\n' + SolrException.toStr(e);
exceptions.add(entry);
}
/**
* Returns a list of facet counts for each of the facet queries
* specified in the params
@ -232,19 +223,12 @@ public class SimpleFacets {
if (null != facetQs && 0 != facetQs.length) {
for (String q : facetQs) {
try {
parseParams(FacetParams.FACET_QUERY, q);
// TODO: slight optimization would prevent double-parsing of any localParams
Query qobj = QParser.getParser(q, null, req).getQuery();
res.add(key, searcher.numDocs(qobj, base));
}
catch (Exception e) {
String msg = "Exception during facet.query of " + q;
SolrException.logOnce(SolrCore.log, msg, e);
addException(msg , e);
}
}
}
return res;
@ -347,7 +331,6 @@ public class SimpleFacets {
String[] facetFs = params.getParams(FacetParams.FACET_FIELD);
if (null != facetFs) {
for (String f : facetFs) {
try {
parseParams(FacetParams.FACET_FIELD, f);
String termList = localParams == null ? null : localParams.get(CommonParams.TERMS);
if (termList != null) {
@ -355,11 +338,6 @@ public class SimpleFacets {
} else {
res.add(key, getTermCounts(facetValue));
}
} catch (Exception e) {
String msg = "Exception during facet.field of " + f;
SolrException.logOnce(SolrCore.log, msg, e);
addException(msg , e);
}
}
}
return res;
@ -780,13 +758,7 @@ public class SimpleFacets {
if (null == fields || 0 == fields.length) return resOuter;
for (String f : fields) {
try {
getFacetDateCounts(f, resOuter);
} catch (Exception e) {
String msg = "Exception during facet.date of " + f;
SolrException.logOnce(SolrCore.log, msg, e);
addException(msg , e);
}
}
return resOuter;
@ -955,20 +927,14 @@ public class SimpleFacets {
* @see FacetParams#FACET_RANGE
*/
public NamedList<Object> getFacetRangeCounts() {
public NamedList<Object> getFacetRangeCounts() throws IOException, ParseException {
final NamedList<Object> resOuter = new SimpleOrderedMap<Object>();
final String[] fields = params.getParams(FacetParams.FACET_RANGE);
if (null == fields || 0 == fields.length) return resOuter;
for (String f : fields) {
try {
getFacetRangeCounts(f, resOuter);
} catch (Exception e) {
String msg = "Exception during facet.range of " + f;
SolrException.logOnce(SolrCore.log, msg, e);
addException(msg , e);
}
}
return resOuter;