public Collection<SolrInputDocument> toDocs(Iterable<JSONObject> messages) { Collection<SolrInputDocument> ret = new ArrayList<>(); for(JSONObject message: messages) { SolrInputDocument document = new SolrInputDocument(); for (Object key : message.keySet()) { Object value = message.get(key); if (value instanceof Iterable) { for (Object v : (Iterable) value) { document.addField("" + key, v); } } else { document.addField("" + key, value); } } if (!document.containsKey(Constants.GUID)) { document.addField(Constants.GUID, UUID.randomUUID().toString()); } ret.add(document); } return ret; }
/** * @param fieldname * @return */ public boolean containsKey(String fieldname) { return doc.containsKey(fieldname); }
/** * @param fieldname * @return */ public boolean containsKey(String fieldname) { return doc.containsKey(fieldname); }
protected String getCurrentFieldValue(SolrInputDocument doc, String fieldName) { StringBuffer sb = new StringBuffer(); if (doc.containsKey(fieldName)) { Object content = doc.getFieldValue(fieldName); if (content instanceof String) { sb.append((String) doc.getFieldValue(fieldName)); sb.append(" "); } else { log.warn("Field " + fieldName + " not a String value, not including in detection"); } } return sb.toString(); }
Element oai_dc = new Element("dc", oaidc); if (doc.containsKey("collections")) { Element subject; Object[] collections = doc.getFieldValues("collections").toArray(); if (doc.containsKey("title")) { title.setText((String) doc.getFieldValues("title").toArray()[0]); } else {
/** * Adds the text field. * * @param solrDocument * the solr document * @param metadata * the metadata * @param name * the name * @param value * the value */ private void addTextField(final SolrInputDocument solrDocument, final Metadata metadata, final String name, final String value, Float boost) { solrDocument.addField(name, value, boost); // set exactSearch field if exists. if (metadata.isSet(Property.EXACT_SEARCHABLE)) { solrDocument.addField(FIELD_EXACTSEARCH_PREFIX + name, Formatter.getExactSearchableTerm(value)); } // set sort field if exists. if (metadata.isSet(Property.SORTABLE)) { if (!solrDocument.containsKey(FIELD_SORT_PREFIX + name)) { solrDocument.addField(FIELD_SORT_PREFIX + name, Formatter.getSortableValue(value), boost); } else { LOG.debug("Encountered multiple values of sortable field:{}. Only first value will be used for sorting.", name); } } }
if (parentDoc.containsKey(TREENODE_ROOT)) { root = SolrUtil.getStringFieldValue(parentDoc, TREENODE_ROOT); Collection<String> p = SolrUtil.getStringFieldValues(parentDoc, TREENODE_PARENTS);
if (parentDoc.containsKey(TREENODE_ROOT)) { root = (String) parentDoc.getFieldValue(TREENODE_ROOT); Collection p = parentDoc.getFieldValues(TREENODE_PARENTS);