Search in sources :

Example 1 with SeparatorFieldPart

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

the class JuniperSearcher method addSeparator.

private void addSeparator(final boolean bolding, final boolean dynteaser, final FieldPart f, final String toQuote, final List<FieldPart> newFieldParts, final int previous, final int j) {
    if (previous != j) {
        newFieldParts.add(new StringFieldPart(toQuote.substring(previous, j), f.isToken()));
    }
    if (dynteaser) {
        final FieldPart s = (bolding ? new SeparatorFieldPart(separatorTag) : new SeparatorFieldPart(ELLIPSIS));
        newFieldParts.add(s);
    }
}
Also used : BoldCloseFieldPart(com.yahoo.prelude.hitfield.BoldCloseFieldPart) SeparatorFieldPart(com.yahoo.prelude.hitfield.SeparatorFieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) BoldOpenFieldPart(com.yahoo.prelude.hitfield.BoldOpenFieldPart) FieldPart(com.yahoo.prelude.hitfield.FieldPart) SeparatorFieldPart(com.yahoo.prelude.hitfield.SeparatorFieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart)

Example 2 with SeparatorFieldPart

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

the class JuniperSearcher method insertTags.

private void insertTags(final HitField oldProperty, final boolean bolding, final boolean dynteaser) {
    boolean insideHighlight = false;
    for (final ListIterator<FieldPart> i = oldProperty.listIterator(); i.hasNext(); ) {
        final FieldPart f = i.next();
        if (f instanceof SeparatorFieldPart) {
            setSeparatorString(bolding, (SeparatorFieldPart) f);
        }
        if (f.isFinal()) {
            continue;
        }
        final String toQuote = f.getContent();
        List<FieldPart> newFieldParts = null;
        int previous = 0;
        for (int j = 0; j < toQuote.length(); j++) {
            final char key = toQuote.charAt(j);
            switch(key) {
                case RAW_HIGHLIGHT_CHAR:
                    newFieldParts = initFieldParts(newFieldParts);
                    addBolding(bolding, insideHighlight, f, toQuote, newFieldParts, previous, j);
                    previous = j + 1;
                    insideHighlight = !insideHighlight;
                    break;
                case RAW_SEPARATOR_CHAR:
                    newFieldParts = initFieldParts(newFieldParts);
                    addSeparator(bolding, dynteaser, f, toQuote, newFieldParts, previous, j);
                    previous = j + 1;
                    break;
                default:
                    // no action
                    break;
            }
        }
        if (previous > 0 && previous < toQuote.length()) {
            newFieldParts.add(new StringFieldPart(toQuote.substring(previous), f.isToken()));
        }
        if (newFieldParts != null) {
            i.remove();
            for (final Iterator<FieldPart> j = newFieldParts.iterator(); j.hasNext(); ) {
                i.add(j.next());
            }
        }
    }
}
Also used : BoldCloseFieldPart(com.yahoo.prelude.hitfield.BoldCloseFieldPart) SeparatorFieldPart(com.yahoo.prelude.hitfield.SeparatorFieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart) BoldOpenFieldPart(com.yahoo.prelude.hitfield.BoldOpenFieldPart) FieldPart(com.yahoo.prelude.hitfield.FieldPart) SeparatorFieldPart(com.yahoo.prelude.hitfield.SeparatorFieldPart) StringFieldPart(com.yahoo.prelude.hitfield.StringFieldPart)

Aggregations

BoldCloseFieldPart (com.yahoo.prelude.hitfield.BoldCloseFieldPart)2 BoldOpenFieldPart (com.yahoo.prelude.hitfield.BoldOpenFieldPart)2 FieldPart (com.yahoo.prelude.hitfield.FieldPart)2 SeparatorFieldPart (com.yahoo.prelude.hitfield.SeparatorFieldPart)2 StringFieldPart (com.yahoo.prelude.hitfield.StringFieldPart)2