private void addBolding(boolean bolding, boolean insideHighlight, FieldPart f, String toQuote,
                            List<FieldPart> newFieldParts, int previous, int j) {
        if (previous != j) {
            newFieldParts.add(new StringFieldPart(toQuote.substring(previous, j), f.isToken()));
        }
        if (bolding) {
            if (insideHighlight) {
                newFieldParts.add(new BoldCloseFieldPart(boldCloseTag));
            } else {
                if (!newFieldParts.isEmpty()
                        && newFieldParts.get(newFieldParts.size() - 1) instanceof BoldCloseFieldPart) {
                    newFieldParts.remove(newFieldParts.size() - 1);
                } else {
                    newFieldParts.add(new BoldOpenFieldPart(boldOpenTag));
                }
            }
        }
    }
This converts the backend binary highlighting of each item in an array of string field,
and creates a new field that replaces the original.
container-search/src/main/java/com/yahoo/prelude/searcher/JuniperSearcher.java