@Override protected PassageFormatter getFormatter(String fieldName) { String preTag = params.getFieldParam(fieldName, HighlightParams.TAG_PRE, "<em>"); String postTag = params.getFieldParam(fieldName, HighlightParams.TAG_POST, "</em>"); String ellipsis = params.getFieldParam(fieldName, HighlightParams.TAG_ELLIPSIS, "... "); String encoder = params.getFieldParam(fieldName, HighlightParams.ENCODER, "simple"); return new DefaultPassageFormatter(preTag, postTag, ellipsis, "html".equals(encoder)); }
@Override protected PassageFormatter getFormatter(String fieldName) { String preTag = params.getFieldParam(fieldName, HighlightParams.TAG_PRE, "<em>"); String postTag = params.getFieldParam(fieldName, HighlightParams.TAG_POST, "</em>"); String ellipsis = params.getFieldParam(fieldName, HighlightParams.TAG_ELLIPSIS, "... "); String encoder = params.getFieldParam(fieldName, HighlightParams.ENCODER, "simple"); return new HighlightFormatter(preTag, postTag, ellipsis, "html".equals(encoder)); }
@Override public void init(PluginInfo info) { Map<String,String> attributes = info.attributes; BreakIterator breakIterator = BreakIterator.getSentenceInstance(Locale.ROOT); PassageScorer scorer = new PassageScorer(); // formatter parameters: preTag/postTag/ellipsis String preTag = attributes.get("preTag"); if (preTag == null) { preTag = "<em>"; } String postTag = attributes.get("postTag"); if (postTag == null) { postTag = "</em>"; } String ellipsis = attributes.get("ellipsis"); if (ellipsis == null) { ellipsis = "... "; } PassageFormatter formatter = new PassageFormatter(preTag, postTag, ellipsis); // maximum content size to process int maxLength = PostingsHighlighter.DEFAULT_MAX_LENGTH; if (attributes.containsKey("maxLength")) { maxLength = Integer.parseInt(attributes.get("maxLength")); } highlighter = new PostingsHighlighter(maxLength, breakIterator, scorer, formatter); }