SOLR-225 - style changes and HighlightUtils.emptyArray() change

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@552689 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Ryan McKinley 2007-07-03 06:29:50 +00:00
parent a517e0f5a9
commit 0985f37184
2 changed files with 25 additions and 20 deletions

View File

@ -18,26 +18,26 @@
package org.apache.solr.common.params;
/**
*
* @author ryan
* @version $Id$
* @since solr 1.3
*/
public interface HighlightParams {
public static final String SIMPLE = "simple";
public static final String HIGHLIGHT = "hl";
public static final String PREFIX = "hl.";
public static final String FIELDS = PREFIX+"fl";
public static final String SNIPPETS = PREFIX+"snippets";
public static final String FRAGSIZE = PREFIX+"fragsize";
public static final String INCREMENT = PREFIX+"increment";
public static final String SLOP = PREFIX+"slop";
public static final String MAX_CHARS = PREFIX+"maxAnalyzedChars";
public static final String FORMATTER = PREFIX+"formatter";
public static final String FRAGMENTER = PREFIX+"fragmenter";
public static final String SIMPLE_PRE = PREFIX+SIMPLE+".pre";
public static final String SIMPLE_POST = PREFIX+SIMPLE+".post";
public static final String FIELD_MATCH = PREFIX+"requireFieldMatch";
public static final String FIELDS = HIGHLIGHT+".fl";
public static final String SNIPPETS = HIGHLIGHT+".snippets";
public static final String FRAGSIZE = HIGHLIGHT+".fragsize";
public static final String INCREMENT = HIGHLIGHT+".increment";
public static final String MAX_CHARS = HIGHLIGHT+".maxAnalyzedChars";
public static final String FORMATTER = HIGHLIGHT+".formatter";
public static final String FRAGMENTER = HIGHLIGHT+".fragmenter";
public static final String FIELD_MATCH = HIGHLIGHT+".requireFieldMatch";
// Formatter
public static final String SIMPLE = "simple";
public static final String SIMPLE_PRE = HIGHLIGHT+"."+SIMPLE+".pre";
public static final String SIMPLE_POST = HIGHLIGHT+"."+SIMPLE+".post";
// Regex fragmenter
public static final String REGEX = "regex";
public static final String SLOP = HIGHLIGHT+"."+REGEX+".slop";
}

View File

@ -22,7 +22,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.LinkedList;
import java.util.ArrayList;
import java.util.ListIterator;
@ -135,7 +134,8 @@ public class HighlightingUtils implements HighlightParams {
}
private static boolean emptyArray(String[] arr) {
return (arr == null || arr.length == 0 || arr[0] == null || arr[0].trim().length() == 0);
return (arr == null || arr.length == 0 ||
(arr.length == 1 && (arr[0] == null || arr[0].trim().length() == 0)));
}
/**
@ -191,6 +191,7 @@ public class HighlightingUtils implements HighlightParams {
* @return NamedList containing a NamedList for each document, which in
* turns contains sets (field, summary) pairs.
*/
@SuppressWarnings("unchecked")
public static NamedList doHighlighting(DocList docs, Query query, SolrQueryRequest req, String[] defaultFields) throws IOException {
if (!isHighlightingEnabled(req))
return null;
@ -257,7 +258,7 @@ public class HighlightingUtils implements HighlightParams {
}
summaries = fragTexts.toArray(new String[0]);
if (summaries.length > 0)
docSummaries.add(fieldName, summaries);
docSummaries.add(fieldName, summaries);
}
}
String printId = searcher.getSchema().printableUniqueKey(doc);
@ -298,6 +299,7 @@ class MultiValueTokenStream extends TokenStream {
}
/** Returns the next token in the stream, or null at EOS. */
@Override
public Token next() throws IOException {
int extra = 0;
if(currentStream == null) {
@ -364,6 +366,7 @@ class GapFragmenter extends SimpleFragmenter {
/* (non-Javadoc)
* @see org.apache.lucene.search.highlight.TextFragmenter#start(java.lang.String)
*/
@Override
public void start(String originalText) {
fragOffsetAccum = 0;
}
@ -371,6 +374,7 @@ class GapFragmenter extends SimpleFragmenter {
/* (non-Javadoc)
* @see org.apache.lucene.search.highlight.TextFragmenter#isNewFragment(org.apache.lucene.analysis.Token)
*/
@Override
public boolean isNewFragment(Token token) {
boolean isNewFrag =
token.endOffset() >= fragOffsetAccum + getFragmentSize() ||
@ -397,6 +401,7 @@ class TokenOrderingFilter extends TokenFilter {
this.windowSize = windowSize;
}
@Override
public Token next() throws IOException {
while (!done && queue.size() < windowSize) {
Token newTok = input.next();