/** * Get all the values for a field. * * @param name name of the field to fetch * @return value of the field or null if not set */ public Collection<Object> getFieldValues(String name) { SolrInputField field = getField(name); if (field != null) { return field.getValues(); } return null; }
/** * Adds a field with the given name, value and boost. If a field with the name already exists, * then it is updated to the new value and boost. * * @param name Name of the field to add * @param value Value of the field * @param boost Boost value for the field */ public void addField(String name, Object value, float boost) { SolrInputField field = _fields.get(name); if (field == null || field.value == null) { setField(name, value, boost); } else { field.addValue(value, boost); } }
/** Generates a simple <add><doc>... XML String with no options */ public String adoc(SolrInputDocument sdoc) { List<String> fields = new ArrayList<String>(); for (SolrInputField sf : sdoc) { for (Object o : sf.getValues()) { fields.add(sf.getName()); fields.add(o.toString()); } } return adoc(fields.toArray(new String[fields.size()])); }
/** * Get the first value for a field. * * @param name name of the field to fetch * @return first value of the field or null if not present */ public Object getFieldValue(String name) { SolrInputField field = getField(name); Object o = null; if (field != null) o = field.getFirstValue(); return o; }
public void setField(String name, Object value, float boost) { SolrInputField field = new SolrInputField(name); _fields.put(name, field); field.setValue(value, boost); }