private void addField(SolrInputDocument doc, String name, String value) { // find if such field already exists if (doc.get(name) == null) { doc.addField(name, value); } else { // for some fields we can't allow multiple values, like ID field phrase, so we have to perform this check SolrInputField f = doc.get(name); boolean valueExists = false; for (Object existingValue : f.getValues()) { if (existingValue == null && value == null) { valueExists = true; break; } if (existingValue != null && value != null && existingValue.equals(value)) { valueExists = true; break; } } if (!valueExists) { f.addValue(value); } } }
private void mapField(SolrInputDocument input, FIELD col) throws SQLException { SolrInputField ifield = input.get(col.name()); if (ifield != null) { Collection<Object> vals = ifield.getValues();
SolrInputField v = solr.getSolrDocument().get(f); if (v.getValueCount() > 1) { Iterator<Object> i = v.getValues().iterator();
private static void addField(SolrInputDocument doc, String name, String value) { // find if such field already exists if (doc.get(name) == null) { // System.out.println("Adding field " + name + " without previous values"); doc.addField(name, value); } else { // for some fields we can't allow multiple values, like ID field phrase, so we have to perform this check SolrInputField f = doc.get(name); for (Object val : f.getValues()) { // fix for boolean values if ((value.equalsIgnoreCase("t") && val.toString().equalsIgnoreCase("true")) || (value.equalsIgnoreCase("f") && val.toString().equalsIgnoreCase("false"))) { return; } if (value.equals(val.toString())) { // if we find such value in the doc, we will not add it again // System.out.println("Field " + name + " already contains value " + value); return; } } // System.out.println("Adding field " + name + " without new value " + value); f.addValue(value); } }
private static void addField(SolrInputDocument doc, String name, String [] values) { // find if such field already exists if (doc.get(name) == null) { doc.addField(name, values); } else { // for some fields we can't allow multiple values, like ID field phrase, so we have to perform this check SolrInputField f = doc.get(name); for (String v : values) { boolean valueAlreadyIn = false; for (Object val : f.getValues()) { if (v.equals(val.toString())) { // if we find such value in the doc, we will not add it again valueAlreadyIn = true; break; } // fix for boolean values if ((v.equalsIgnoreCase("t") && val.toString().equalsIgnoreCase("true")) || (v.equalsIgnoreCase("f") && val.toString().equalsIgnoreCase("false"))) { valueAlreadyIn = true; break; } } if (!valueAlreadyIn) { f.addValue(v); } } } }
private static SolrInputDocument validateDescriptiveMetadataFields(SolrInputDocument doc) { if (doc.get(RodaConstants.AIP_DATE_INITIAL) != null) { Object value = doc.get(RodaConstants.AIP_DATE_INITIAL).getValue(); if (value instanceof String) { try { Date d = parseDate((String) value); doc.setField(RodaConstants.AIP_DATE_INITIAL, d); } catch (ParseException pe) { doc.remove(RodaConstants.AIP_DATE_INITIAL); doc.setField(RodaConstants.AIP_DATE_INITIAL + "_txt", value); } } } if (doc.get(RodaConstants.AIP_DATE_FINAL) != null) { Object value = doc.get(RodaConstants.AIP_DATE_FINAL).getValue(); if (value instanceof String) { try { Date d = parseDate((String) value); doc.setField(RodaConstants.AIP_DATE_FINAL, d); } catch (ParseException pe) { doc.remove(RodaConstants.AIP_DATE_FINAL); doc.setField(RodaConstants.AIP_DATE_FINAL + "_txt", value); } } } return doc; }
this.data.put(String.valueOf(crtTerm.get(ID_FIELD).getFirstValue()), crtTerm);
SolrInputDocument premisSolrDoc = PremisV3Utils.getSolrDocument(premisFile); doc.putAll(premisSolrDoc); sizeInBytes = SolrUtils.objectToLong(premisSolrDoc.get(RodaConstants.FILE_SIZE).getValue(), 0L); } catch (GenericException e) { LOGGER.warn("Could not index file PREMIS information", e);