diff --git a/CHANGES.txt b/CHANGES.txt index f1199d09f08..a0e0311e5e9 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -99,6 +99,7 @@ Bug Fixes the behavior of a non-distributed request since it only returned the id,score fields instead of all fields in addition to score. (yonik) +* SOLR-1601: Schema browser does not indicate presence of charFilter. (koji) Other Changes ---------------------- diff --git a/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java b/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java index c5d06f49cb1..b4b521b3f5b 100644 --- a/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java +++ b/src/java/org/apache/solr/handler/admin/LukeRequestHandler.java @@ -44,6 +44,7 @@ import org.apache.lucene.search.ConstantScoreRangeQuery; import org.apache.lucene.search.TopDocs; import org.apache.lucene.store.Directory; import org.apache.lucene.util.PriorityQueue; +import org.apache.solr.analysis.CharFilterFactory; import org.apache.solr.analysis.TokenFilterFactory; import org.apache.solr.analysis.TokenizerChain; import org.apache.solr.analysis.TokenizerFactory; @@ -391,25 +392,40 @@ public class LukeRequestHandler extends RequestHandlerBase SimpleOrderedMap aninfo = new SimpleOrderedMap(); aninfo.add("className", analyzer.getClass().getName()); if (analyzer instanceof TokenizerChain) { - SimpleOrderedMap tokenizer = new SimpleOrderedMap(); - TokenizerChain tchain = (TokenizerChain)analyzer; - TokenizerFactory tfac = tchain.getTokenizerFactory(); - tokenizer.add("className", tfac.getClass().getName()); - tokenizer.add("args", tfac.getArgs()); - aninfo.add("tokenizer", tokenizer); - TokenFilterFactory[] filtfacs = tchain.getTokenFilterFactories(); - - SimpleOrderedMap> filters = new SimpleOrderedMap>(); - for (TokenFilterFactory filtfac : filtfacs) { - Map tok = new HashMap(); - String className = filtfac.getClass().getName(); - tok.put("className", className); - tok.put("args", filtfac.getArgs()); - filters.add(className.substring(className.lastIndexOf('.')+1), tok); - } - if (filters.size() > 0) { - aninfo.add("filters", filters); - } + + TokenizerChain tchain = (TokenizerChain)analyzer; + + CharFilterFactory[] cfiltfacs = tchain.getCharFilterFactories(); + SimpleOrderedMap> cfilters = new SimpleOrderedMap>(); + for (CharFilterFactory cfiltfac : cfiltfacs) { + Map tok = new HashMap(); + String className = cfiltfac.getClass().getName(); + tok.put("className", className); + tok.put("args", cfiltfac.getArgs()); + cfilters.add(className.substring(className.lastIndexOf('.')+1), tok); + } + if (cfilters.size() > 0) { + aninfo.add("charFilters", cfilters); + } + + SimpleOrderedMap tokenizer = new SimpleOrderedMap(); + TokenizerFactory tfac = tchain.getTokenizerFactory(); + tokenizer.add("className", tfac.getClass().getName()); + tokenizer.add("args", tfac.getArgs()); + aninfo.add("tokenizer", tokenizer); + + TokenFilterFactory[] filtfacs = tchain.getTokenFilterFactories(); + SimpleOrderedMap> filters = new SimpleOrderedMap>(); + for (TokenFilterFactory filtfac : filtfacs) { + Map tok = new HashMap(); + String className = filtfac.getClass().getName(); + tok.put("className", className); + tok.put("args", filtfac.getArgs()); + filters.add(className.substring(className.lastIndexOf('.')+1), tok); + } + if (filters.size() > 0) { + aninfo.add("filters", filters); + } } return aninfo; } diff --git a/src/webapp/web/admin/schema.jsp b/src/webapp/web/admin/schema.jsp index b1a1b6216ab..5a11dcc5e77 100644 --- a/src/webapp/web/admin/schema.jsp +++ b/src/webapp/web/admin/schema.jsp @@ -282,7 +282,7 @@ //Displays information about an Analyzer in the main content area displayAnalyzer: function(analyzer, type, shouldCollapse) { var tid = type.replace(' ', ''); - var collapse = shouldCollapse && (analyzer.tokenizer != undefined || analyzer.filters != undefined); + var collapse = shouldCollapse && (analyzer.charFilters != undefined || analyzer.tokenizer != undefined || analyzer.filters != undefined); $('#mainInfo').append(solr.createNameValueText(type, function(p) { p.appendChild(document.createTextNode(analyzer.className + ' ')); if (collapse) { @@ -298,6 +298,24 @@ if (collapse) { adiv.style.display='none'; } + if (analyzer.charFilters != undefined) { + adiv.appendChild(solr.createNameValueText('Char Filters', '')); + var f = document.createElement('ol'); + $.each(analyzer.charFilters, function(i, item) { + var fil = document.createElement('li'); + var filterText = item.className; + if (item.args != undefined) { + filterText += ' args:{' + $.each(item.args, function(fi, fitem) { + filterText += fi + ': ' + fitem + ' '; + }); + filterText +='}'; + fil.innerHTML = filterText; + f.appendChild(fil); + } + }); + adiv.appendChild(f); + } if (analyzer.tokenizer != undefined) { adiv.appendChild(solr.createNameValueText("Tokenizer Class", analyzer.tokenizer.className)); }