static boolean serialize(StringBuilder destination, PhraseItem phrase, boolean includeField) {
            String annotations = leafAnnotations(phrase);

            if (includeField)
                destination.append(normalizeIndexName(phrase.getIndexName())).append(" contains ");
            if (!annotations.isEmpty())
                destination.append("({").append(annotations).append("}");

            destination.append(PHRASE).append('(');
            for (int i = 0; i < phrase.getItemCount(); ++i) {
                if (i > 0)
                    destination.append(", ");
                Item current = phrase.getItem(i);
                if (current instanceof WordItem) {
                    WordSerializer.serializeWordWithoutIndex(destination, current);
                } else if (current instanceof PhraseSegmentItem) {
                    PhraseSegmentSerializer.serialize(destination, current, false);
                } else if (current instanceof WordAlternativesItem) {
                    WordAlternativesSerializer.serialize(destination, (WordAlternativesItem) current, false);
                } else {
                    throw new IllegalArgumentException("Serializing of " + current.getClass().getSimpleName() +
                                                       " in phrases not implemented, please report this as a bug.");
                }
            }
            destination.append(')');
            if (!annotations.isEmpty())
                destination.append(')');
            return false;
        }
Serialize Vespa query trees to YQL+ strings.

@author Steinar Knutsen
container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java