diff --git a/CHANGES.txt b/CHANGES.txt index c0f46a0806a..d9191a5bafa 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -269,7 +269,9 @@ New Features 68. SOLR-1367: Added callback mechanism for converting DocList to SolrDocumentList in SolrPluginUtils (gsingers) -68. SOLR-1275: Add expungeDeletes to DirectUpdateHandler2 (noble) +69. SOLR-1275: Add expungeDeletes to DirectUpdateHandler2 (noble) + +70. SOLR-1372: Enhance FieldAnalysisRequestHandler to accept field value from content stream (ehatcher) Optimizations diff --git a/src/java/org/apache/solr/handler/FieldAnalysisRequestHandler.java b/src/java/org/apache/solr/handler/FieldAnalysisRequestHandler.java index 8a1997faf70..d4c2021d486 100644 --- a/src/java/org/apache/solr/handler/FieldAnalysisRequestHandler.java +++ b/src/java/org/apache/solr/handler/FieldAnalysisRequestHandler.java @@ -24,14 +24,18 @@ import org.apache.solr.common.params.CommonParams; import org.apache.solr.common.params.SolrParams; import org.apache.solr.common.util.NamedList; import org.apache.solr.common.util.SimpleOrderedMap; +import org.apache.solr.common.util.ContentStream; import org.apache.solr.request.SolrQueryRequest; import org.apache.solr.schema.FieldType; import org.apache.solr.schema.IndexSchema; +import org.apache.commons.io.IOUtils; import java.util.Arrays; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.io.Reader; +import java.io.IOException; /** * RequestHandler that provides much the same functionality as analysis.jsp. Provides the ability to specify multiple @@ -146,7 +150,28 @@ public class FieldAnalysisRequestHandler extends AnalysisRequestHandlerBase { analysisRequest.addFieldName(req.getSchema().getDefaultSearchFieldName()); } analysisRequest.setQuery(solrParams.get(AnalysisParams.QUERY, solrParams.get(CommonParams.Q))); - analysisRequest.setFieldValue(solrParams.get(AnalysisParams.FIELD_VALUE)); + + String value = solrParams.get(AnalysisParams.FIELD_VALUE); + + Iterable streams = req.getContentStreams(); + if (streams != null) { + // NOTE: Only the first content stream is currently processed + for (ContentStream stream : streams) { + Reader reader = null; + try { + reader = stream.getReader(); + value = IOUtils.toString(reader); + } catch (IOException e) { + // do nothing, leave value set to the request parameter + } + finally { + IOUtils.closeQuietly(reader); + } + break; + } + } + + analysisRequest.setFieldValue(value); analysisRequest.setShowMatch(solrParams.getBool(AnalysisParams.SHOW_MATCH, false)); return analysisRequest; }