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

@ -52,7 +52,9 @@ Upgrading from Solr 3.3-dev
If q.op is effectively "OR" then mm=0%. Users who wish to force the
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
----------------------
@ -212,6 +214,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,18 +223,11 @@ public class SimpleFacets {
if (null != facetQs && 0 != facetQs.length) {
for (String q : facetQs) {
try {
parseParams(FacetParams.FACET_QUERY, q);
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);
}
// 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));
}
}
@ -347,18 +331,12 @@ 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) {
res.add(key, getListedTermCounts(facetValue, termList));
} 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);
parseParams(FacetParams.FACET_FIELD, f);
String termList = localParams == null ? null : localParams.get(CommonParams.TERMS);
if (termList != null) {
res.add(key, getListedTermCounts(facetValue, termList));
} else {
res.add(key, getTermCounts(facetValue));
}
}
}
@ -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);
}
getFacetDateCounts(f, resOuter);
}
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);
}
getFacetRangeCounts(f, resOuter);
}
return resOuter;