Exemplo n.º 1
0
 public static String getValueFromField(SearchInputDocument doc, String fieldName) {
   SearchInputField field = doc.getField(fieldName);
   if (field == null) {
     return "UNKNOWN";
   } else {
     Object value = field.getFirstValue();
     return (value == null) ? "UNKNOWN" : String.valueOf(value);
   }
 }
Exemplo n.º 2
0
  public static String format(SearchInputDocument doc) {
    StringBuilder sb = new StringBuilder();
    sb.append(
        "SearchInputDocument: Name='"
            + getValueFromField(doc, "nameRaw")
            + "', URI='"
            + getValueFromField(doc, "URI")
            + "', boost='"
            + doc.getDocumentBoost()
            + "', "
            + doc.getFieldMap().size()
            + " fields \n");

    for (SearchInputField field : new TreeMap<>(doc.getFieldMap()).values()) {
      sb.append(format(field, "   ").append('\n'));
    }

    return sb.toString();
  }