Refine search
private void deleteIndividualFieldsFromIndex(String collectionName, String keyIdField, String docId, HashSet<IndexEntry> fieldDeletions) throws SolrServerException, IOException { if (fieldDeletions.isEmpty()) return; Map<String, String> fieldDeletes = new HashMap<String, String>(1) {{ put("set", null); }}; SolrInputDocument doc = new SolrInputDocument(); doc.addField(keyIdField, docId); StringBuilder sb = new StringBuilder(); for (IndexEntry fieldToDelete : fieldDeletions) { doc.addField(fieldToDelete.field, fieldDeletes); sb.append(fieldToDelete).append(","); } if (logger.isTraceEnabled()) logger.trace("Deleting individual fields [{}] for document {}", sb.toString(), docId); UpdateRequest singleDocument = newUpdateRequest(); singleDocument.add(doc); solrClient.request(singleDocument, collectionName); }
public SolrInputDocument toSolrInputDocument(SolrDocument d) { final SolrInputDocument doc = new SolrInputDocument(); for (String name : d.getFieldNames()) { doc.addField(name, d.getFieldValue(name)); } return doc; } }
public Status update(String table, String key, Map<String, ByteIterator> values) { try { SolrInputDocument updatedDoc = new SolrInputDocument(); updatedDoc.addField("id", key); updatedDoc.addField(entry.getKey(), Collections.singletonMap("set", entry.getValue()));
public Status update(String table, String key, Map<String, ByteIterator> values) { try { SolrInputDocument updatedDoc = new SolrInputDocument(); updatedDoc.addField("id", key); updatedDoc.addField(entry.getKey(), Collections.singletonMap("set", entry.getValue()));
public Status insert(String table, String key, Map<String, ByteIterator> values) { try { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", key); for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { doc.addField(entry.getKey(), entry.getValue());
public Status insert(String table, String key, Map<String, ByteIterator> values) { try { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", key); for (Entry<String, String> entry : StringByteIterator.getStringMap(values).entrySet()) { doc.addField(entry.getKey(), entry.getValue());
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; }
public static SolrInputDocument toSolrInputDocument(Document document) { SolrInputDocument solrInputDocument = new SolrInputDocument(); for (Map.Entry<String, Object> field : document.getDocument().entrySet()) { if (field.getKey().equals(MetaAlertConstants.ALERT_FIELD)) { // We have a children, that needs to be translated as a child doc, not a field. List<Map<String, Object>> alerts = (List<Map<String, Object>>) field.getValue(); for (Map<String, Object> alert : alerts) { SolrInputDocument childDocument = new SolrInputDocument(); for (Map.Entry<String, Object> alertField : alert.entrySet()) { childDocument.addField(alertField.getKey(), alertField.getValue()); } solrInputDocument.addChildDocument(childDocument); } } else { solrInputDocument.addField(field.getKey(), field.getValue()); } } return solrInputDocument; }
public SolrInputDocument toSolrInputDocument(){ SolrInputDocument solrInputDocument = new SolrInputDocument(); solrInputDocument.addField(HOSTNAME, hostname); solrInputDocument.addField(PORT, portNumber); solrInputDocument.addField(TIMESTAMP, new Date()); solrInputDocument.addField(POOL, pool); solrInputDocument.addField(CORENAME, coreName); solrInputDocument.addField(SOURCE, source); return solrInputDocument; }
SolrInputDocument parentDoc = new SolrInputDocument(); parentDoc.addField("id", "parent_1"); parentDoc.addField("name_s", "Sarah Connor"); parentDoc.addField("blockJoinId", "1"); solrClient.add(parentDoc); solrClient.commit();
// Adds a document containing two fields: id and first_name, with // values "123" and "randombee" respectively SolrInputDocument document = new SolrInputDocument(); document.addField("id", "123"); document.addField("first_name", "randombee"); solr.add(document); solr.commit(); // you MUST do this to commit the changes to your collection
SolrInputDocument parentDocUpdateing = new SolrInputDocument(); parentDocUpdateing.addField("id", "parent_1"); parentDocUpdateing.addField("name_s", "Sarah Connor"); parentDocUpdateing.addField("blockJoinId", "1"); SolrInputDocument childDoc = new SolrInputDocument(); childDoc.addField("id", "child_1"); childDoc.addField("name_s", "John Connor"); childDoc.addField("blockJoinId", "1"); parentDocUpdateing.addChildDocument(childDoc); solrClient.add(parentDocUpdateing); solrClient.commit();
public static SolrInputDocument sdoc(Object... fieldsAndValues) { SolrInputDocument sd = new SolrInputDocument(); for (int i=0; i<fieldsAndValues.length; i+=2) { sd.addField((String)fieldsAndValues[i], fieldsAndValues[i+1]); } return sd; }
private static SolrInputDocument createUpdateDocument(String id, String collection, String collections) { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", id); Map<String, String> collection_op = new HashMap<String, String>(); collection_op.put("set", collection); doc.addField("collection", collection_op); Map<String, String> collections_op = new HashMap<String, String>(); collections_op.put("set", collections); doc.addField("collections", collections_op); return doc; }
private static SolrInputDocument createUpdateDocument(String id, String collection, String collections) { SolrInputDocument doc = new SolrInputDocument(); doc.addField("id", id); Map<String, String> collection_op = new HashMap<String, String>(); collection_op.put("set", collection); doc.addField("collection", collection_op); Map<String, String> collections_op = new HashMap<String, String>(); collections_op.put("set", collections); doc.addField("collections", collections_op); return doc; }
CommonsHttpSolrServer server = new CommonsHttpSolrServer(MY_SERVER_URL); SolrInputDocument doc = new SolrInputDocument(); UUID uuid = UUID.randomUUID(); doc.addField("id", uuid.toString()); // [...] multiple addField calls server.add(doc); UpdateResponse ur = server.commit();
private void loadVersion() { SolrInputDocument metaTerm = new SolrInputDocument(); metaTerm.addField(ID_FIELD, "HEADER_INFO"); metaTerm.addField("version", ISODateTimeFormat.dateTime().withZoneUTC().print(new DateTime())); this.data.put("VERSION", metaTerm); } }
private void addMetaInfo(Collection<SolrInputDocument> data) { SolrInputDocument metaTerm = new SolrInputDocument(); metaTerm.addField(ID_FIELD_NAME, "HEADER_INFO"); metaTerm.addField(VERSION_FIELD_NAME, ISODateTimeFormat.dateTime().withZoneUTC().print(new DateTime())); data.add(metaTerm); } }
private void addMetaInfo(Collection<SolrInputDocument> data) { SolrInputDocument metaTerm = new SolrInputDocument(); metaTerm.addField(ID_FIELD_NAME, "HEADER_INFO"); metaTerm.addField(VERSION_FIELD_NAME, ISODateTimeFormat.dateTime().withZoneUTC().print(new DateTime())); data.add(metaTerm); } }
public static SolrInputDocument createSolrDoc(DvObjectSolrDoc dvObjectSolrDoc) { if (dvObjectSolrDoc == null) { return null; } SolrInputDocument solrInputDocument = new SolrInputDocument(); solrInputDocument.addField(SearchFields.ID, dvObjectSolrDoc.getSolrId() + IndexServiceBean.discoverabilityPermissionSuffix); solrInputDocument.addField(SearchFields.DEFINITION_POINT, dvObjectSolrDoc.getSolrId()); solrInputDocument.addField(SearchFields.DEFINITION_POINT_DVOBJECT_ID, dvObjectSolrDoc.getDvObjectId()); solrInputDocument.addField(SearchFields.DISCOVERABLE_BY, dvObjectSolrDoc.getPermissions()); return solrInputDocument; }