Search in sources :

Example 1 with ImmutableFieldPart

use of com.yahoo.prelude.hitfield.ImmutableFieldPart in project vespa by vespa-engine.

the class QuotingSearcher method translate.

private List<FieldPart> translate(String toQuote, QuoteTable translations, boolean isToken) {
    List<FieldPart> newFieldParts = null;
    int lastIdx = 0;
    for (int i = 0; i < toQuote.length(); i++) {
        String quote = translations.get(toQuote.charAt(i));
        if (quote != null) {
            if (newFieldParts == null) {
                newFieldParts = new ArrayList<>();
            }
            if (lastIdx != i) {
                newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx, i), isToken));
            }
            String initContent = Character.toString(toQuote.charAt(i));
            newFieldParts.add(new ImmutableFieldPart(initContent, quote, isToken));
            lastIdx = i + 1;
        }
    }
    if (lastIdx > 0 && lastIdx < toQuote.length()) {
        newFieldParts.add(new StringFieldPart(toQuote.substring(lastIdx), isToken));
    }
    return newFieldParts;
}
Also used : FieldPart(com.yahoo.prelude.hitfield.FieldPart) ImmutableFieldPart(com.yahoo.prelude.hitfield.ImmutableFieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) ImmutableFieldPart(com.yahoo.prelude.hitfield.ImmutableFieldPart)

Aggregations

FieldPart (com.yahoo.prelude.hitfield.FieldPart)1 ImmutableFieldPart (com.yahoo.prelude.hitfield.ImmutableFieldPart)1 StringFieldPart (com.yahoo.prelude.hitfield.StringFieldPart)1