@Override public void addDocuments(Collection<SolrInputDocument> documents) throws IOException, SolrServerException { solrConfiguration.getServer().add(documents); logDocuments(documents); }
solrServer.add(documents); commit(solrServer);
for (Entry<String, Collection<SolrInputDocument>> entry : solrCollectionUpdates .entrySet()) { this.client.add(entry.getKey(), entry.getValue());
@Override public Document update(Document update, Optional<String> rawIndex) throws IOException { Document newVersion = update; // Handle any case where we're given comments in Map form, instead of raw String Object commentsObj = update.getDocument().get(COMMENTS_FIELD); if ( commentsObj instanceof List && ((List<Object>) commentsObj).size() > 0 && ((List<Object>) commentsObj).get(0) instanceof Map) { newVersion = new Document(update); convertCommentsToRaw(newVersion.getDocument()); } try { SolrInputDocument solrInputDocument = SolrUtilities.toSolrInputDocument(newVersion); Optional<String> index = SolrUtilities .getIndex(config.getIndexSupplier(), newVersion.getSensorType(), rawIndex); if (index.isPresent()) { this.client.add(index.get(), solrInputDocument); this.client.commit(index.get()); } else { throw new IllegalStateException("Index must be specified or inferred."); } } catch (SolrServerException e) { throw new IOException(e); } return newVersion; }
/** * Adds a collection of documents * * @param docs the collection of documents * * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} from the server * * @throws IOException if there is a communication error with the server * @throws SolrServerException if there is an error on the server */ public UpdateResponse add(Collection<SolrInputDocument> docs) throws SolrServerException, IOException { return add(null, docs); }
private void loadBatch() throws SolrServerException, IOException { numLoadedDocs += batch.size(); try { UpdateResponse rsp = client.add(batch); } finally { batch.clear(); } }
@Override public List<UpdateResponse> run(List<SolrInputDocument> docs) { UpdateResponse response = null; try { response = client.add(docs); } catch (SolrServerException | IOException e) { logger.error(e.toString(), e); } return Collections.nCopies(docs.size(), response); } }
private void sendLoads(List<SolrInputDocument> loads) throws SolrServerException, IOException { if (loads.size() > 0) { log(server.add(loads)); loads.clear(); } }
/** * Indexes the document in both the control client, and a randomly selected client */ protected void indexDoc(SolrInputDocument doc) throws IOException, SolrServerException { controlClient.add(doc); if (shardCount == 0) {//mostly for temp debugging return; } int which = (doc.getField(id).toString().hashCode() & 0x7fffffff) % clients.size(); SolrClient client = clients.get(which); client.add(doc); }
@Override protected void addDocument(SearchDocument doc) throws IOException { SolrDocument document = ((SolrSearchDocument)doc).getDocument(); try { client.add(ClientUtils.toSolrInputDocument(document)); } catch (SolrServerException e) { throw new IOException(e); } }
@Override protected void addDocument(SearchDocument doc) throws IOException { SolrDocument document = ((SolrSearchDocument)doc).getDocument(); try { client.add(SolrUtil.toSolrInputDocument(document)); } catch (SolrServerException e) { throw new IOException(e); } }
@Override public UpdateResponse saveDocuments(String collection, Collection<SolrInputDocument> documents, Duration commitWithin) { return execute(solrClient -> solrClient.add(collection, documents, getCommitWithinTimeout(commitWithin))); }
@Override public UpdateResponse saveBeans(String collection, Collection<?> beans, Duration commitWithin) { return execute(solrClient -> solrClient.add(collection, convertBeansToSolrInputDocuments(beans), getCommitWithinTimeout(commitWithin))); }
/** * Commits the batch of newly-processed documents. */ protected void commitTerms(Collection<SolrInputDocument> batch) throws SolrServerException, IOException, OutOfMemoryError { this.externalServicesAccess.getReplacementSolrConnection(this).add(batch); this.externalServicesAccess.getReplacementSolrConnection(this).commit(); }
@Override public UpdateResponse saveBean(String collection, Object obj, Duration commitWithin) { assertNoCollection(obj); return execute(solrClient -> solrClient.add(collection, convertBeanToSolrInputDocument(obj), getCommitWithinTimeout(commitWithin))); }
@Override public boolean updateDocuments(DeleteRule rule, List<FlintDocument> documents) throws IndexException { // delete first if (rule != null) deleteDocuments(rule); // add then try { UpdateResponse resp = this._client.add(this._collection, SolrUtils.toDocuments(documents)); return resp.getStatus() == 0; } catch (SolrServerException | IOException ex) { throw new IndexException("Failed to add document(s)", ex); } }