public static UpdateRequest getRequest(Map stormConf, String boltType) { int commitWithin = ConfUtils.getInt(stormConf, "solr." + boltType + ".commit.within", -1); UpdateRequest request = new UpdateRequest(); if (commitWithin != -1) { request.setCommitWithin(commitWithin); } return request; }
private void processUpdate( SolrServer server, UpdateRequest update, boolean isImmediate) throws IOException, SolrServerException { if (isImmediate) { double commitWithin = getEffectiveCommitWithin(); if (commitWithin > 0.0) { update.setCommitWithin((int) (commitWithin * 1000)); } } update.process(server); }
/** * Deletes a list of documents by unique ID, specifying max time before commit * * @param collection the Solr collection to delete the documents from * @param ids the list of document IDs to delete; must be non-null and contain elements * @param commitWithinMs max time (in ms) before a commit will happen * * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since 5.1 */ public UpdateResponse deleteById(String collection, List<String> ids, int commitWithinMs) throws SolrServerException, IOException { if (ids == null) throw new IllegalArgumentException("'ids' parameter must be non-null"); if (ids.isEmpty()) throw new IllegalArgumentException("'ids' parameter must not be empty; should contain IDs to delete"); UpdateRequest req = new UpdateRequest(); req.deleteById(ids); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
update.setCommitWithin(commitWithin);
update.setCommitWithin(commitWithin);
final UpdateRequest update = new UpdateRequest(); if (!immediateCommit) { update.setCommitWithin(commitWithin);
final UpdateRequest update = new UpdateRequest(); if (!immediateCommit) { update.setCommitWithin(commitWithin);
/** * Adds a single document specifying max time before it becomes committed * * @param collection the Solr collection to add the document to * @param doc the input document * @param commitWithinMs max time (in ms) before a commit will happen * * @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 * * @since solr 5.1 */ public UpdateResponse add(String collection, SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.add(doc); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
@Override public UpdateResponse update(UpdateRequest request) throws TranslatorException { try { request.setCommitWithin(-1); request.setAction(UpdateRequest.ACTION.COMMIT, false, false ); return request.process(this.server); } catch (SolrServerException e) { throw new TranslatorException(e); } catch (IOException e) { throw new TranslatorException(e); } }
/** * Adds a collection of documents, specifying max time before they become committed * * @param collection the Solr collection to add documents to * @param docs the collection of documents * @param commitWithinMs max time (in ms) before a commit will happen * * @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 * * @since Solr 5.1 */ public UpdateResponse add(String collection, Collection<SolrInputDocument> docs, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.add(docs); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
/** * Adds a single document specifying max time before it becomes committed * * @param collection the Solr collection to add the document to * @param doc the input document * @param commitWithinMs max time (in ms) before a commit will happen * * @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 * * @since solr 5.1 */ public UpdateResponse add(String collection, SolrInputDocument doc, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.add(doc); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
/** * Deletes a single document by unique ID, specifying max time before commit * * @param collection the Solr collection to delete the document from * @param id the ID of the document to delete * @param commitWithinMs max time (in ms) before a commit will happen * * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since 5.1 */ public UpdateResponse deleteById(String collection, String id, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.deleteById(id); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
/** * Deletes documents from the index based on a query, specifying max time before commit * * @param collection the Solr collection to delete the documents from * @param query the query expressing what documents to delete * @param commitWithinMs max time (in ms) before a commit will happen * * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since 5.1 */ public UpdateResponse deleteByQuery(String collection, String query, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.deleteByQuery(query); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
/** * Adds a collection of documents, specifying max time before they become committed * * @param collection the Solr collection to add documents to * @param docs the collection of documents * @param commitWithinMs max time (in ms) before a commit will happen * * @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 * * @since Solr 5.1 */ public UpdateResponse add(String collection, Collection<SolrInputDocument> docs, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.add(docs); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
@Override public UpdateResponse update(UpdateRequest request) throws TranslatorException { try { request.setCommitWithin(-1); request.setAction(UpdateRequest.ACTION.COMMIT, false, false ); return request.process(this.server); } catch (SolrServerException e) { throw new TranslatorException(e); } catch (IOException e) { throw new TranslatorException(e); } }
/** * Deletes a list of documents by unique ID, specifying max time before commit * * @param collection the Solr collection to delete the documents from * @param ids the list of document IDs to delete * @param commitWithinMs max time (in ms) before a commit will happen * * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since 5.1 */ public UpdateResponse deleteById(String collection, List<String> ids, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.deleteById(ids); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
private void sendDeletes(List deletes) throws SolrServerException, IOException { if (deletes.size() > 0) { UpdateRequest req = new UpdateRequest(); for (Object delete : deletes) { if (delete instanceof String) { req.deleteById((String)delete); // add the delete to the req list } else { String query = ((QueryStringHolder)delete).getQuery(); req.deleteByQuery(query); // add the delete to the req list } } req.setCommitWithin(-1); log(req.process(server)); deletes.clear(); } }
private void sendDeletes(List deletes) throws SolrServerException, IOException { if (deletes.size() > 0) { UpdateRequest req = new UpdateRequest(); for (Object delete : deletes) { if (delete instanceof String) { req.deleteById((String)delete); // add the delete to the req list } else { String query = ((QueryStringHolder)delete).getQuery(); req.deleteByQuery(query); // add the delete to the req list } } req.setCommitWithin(-1); log(req.process(server)); deletes.clear(); } }
/** * Deletes a single document by unique ID, specifying max time before commit * * @param collection the Solr collection to delete the document from * @param id the ID of the document to delete * @param commitWithinMs max time (in ms) before a commit will happen * * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since 5.1 */ public UpdateResponse deleteById(String collection, String id, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.deleteById(id); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }
/** * Deletes documents from the index based on a query, specifying max time before commit * * @param collection the Solr collection to delete the documents from * @param query the query expressing what documents to delete * @param commitWithinMs max time (in ms) before a commit will happen * * @return an {@link org.apache.solr.client.solrj.response.UpdateResponse} containing the response * from the server * * @throws IOException If there is a low-level I/O error. * @throws SolrServerException if there is an error on the server * * @since 5.1 */ public UpdateResponse deleteByQuery(String collection, String query, int commitWithinMs) throws SolrServerException, IOException { UpdateRequest req = new UpdateRequest(); req.deleteByQuery(query); req.setCommitWithin(commitWithinMs); return req.process(this, collection); }