public String relevanceFeedback(TreeSet<SolrDocument> input) {
    // TODO make a complete list of accepted fields that should be used in
    // relevance feedback. ID, for example, is not wanted

    StringBuilder query = new StringBuilder();
    for (SolrDocument doc : input) {
      // Collection<String> fields = doc.getFieldNames();
      for (int i = 0; i < ACCEPTED_REL_FEEDBACK_FIELDS.length; i++) {
        Object fieldVal = doc.getFieldValue(ACCEPTED_REL_FEEDBACK_FIELDS[i]);
        if (fieldVal == null) {
          continue;
        }
        String value = null;
        try { // Try if value is a String, if not, try if it is
            // arraylist
          value = (String) fieldVal;
        } catch (Exception e) {

        }
        if (value == null) {
          // Try if the field is an arraylist of strings instead of a
          // String
          try {
            ArrayList<String> list = (ArrayList<String>) doc
                .getFieldValue(ACCEPTED_REL_FEEDBACK_FIELDS[i]);
          } catch (Exception e) {
            System.err
                .println("The field "
                    + ACCEPTED_REL_FEEDBACK_FIELDS[i]
                    + " is neither String or Arraylist<String>, field not "
                    + "used in relevance feedback");
          }
        }
        if (value != null) {
          // Need to replace ":" by " " because ":" means searching
          // for a field.
          query.append(value);
        }
      }
    }
    return query.toString();
  }