private static String leafAnnotations(TaggableItem item) {
        // TODO: There is no usable API for the general annotations map in the Item instances
        StringBuilder annotation = new StringBuilder();
        int initLen = annotation.length();
        {
            int uniqueId = item.getUniqueID();
            double connectivity = item.getConnectivity();
            TaggableItem connectedTo = (TaggableItem) item.getConnectedItem();
            double significance = item.getSignificance();
            if (connectedTo != null && connectedTo.getUniqueID() != 0) {
                annotation.append(CONNECTIVITY).append(": {")
                        .append(CONNECTION_ID).append(": ")
                        .append(connectedTo.getUniqueID()).append(", ")
                        .append(CONNECTION_WEIGHT).append(": ")
                        .append(connectivity).append("}");
            }
            if (item.hasExplicitSignificance()) {
                comma(annotation, initLen);
                annotation.append(SIGNIFICANCE).append(": ").append(significance);
            }
            if (uniqueId != 0) {
                comma(annotation, initLen);
                annotation.append(UNIQUE_ID).append(": ").append(uniqueId);
            }
        }
        {
            Item leaf = (Item) item;
            boolean filter = leaf.isFilter();
            boolean isRanked = leaf.isRanked();
            String label = leaf.getLabel();
            int weight = leaf.getWeight();

            if (filter) {
                comma(annotation, initLen);
                annotation.append(FILTER).append(": true");
            }
            if ( ! isRanked) {
                comma(annotation, initLen);
                annotation.append(RANKED).append(": false");
            }
            if (label != null) {
                comma(annotation, initLen);
                annotation.append(LABEL).append(": \"");
                escape(label, annotation);
                annotation.append("\"");
            }
            if (weight != 100) {
                comma(annotation, initLen);
                annotation.append(WEIGHT).append(": ").append(weight);
            }
        }
        if (item instanceof IntItem) {
            int hitLimit = ((IntItem) item).getHitLimit();
            if (hitLimit != 0) {
                comma(annotation, initLen);
                annotation.append(HIT_LIMIT).append(": ").append(hitLimit);
            }
        }
        return annotation.toString();
    }
Adds annotations and returns whether any were added
container-search/src/main/java/com/yahoo/search/yql/VespaSerializer.java