/** * Adds the given document to the solr index without commit. * * @param doc the document to add * @throws IOException iff something goes wrong */ public void add(SolrInputDocument doc) throws IOException { AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = doc; cmd.commitWithin = COMMIT_WITHIN; updateProcessor.processAdd(cmd); }
private void storeDocument(SolrInputDocument document, UpdateRequestProcessor processor, SolrQueryRequest req) throws IOException { LOGGER.debug("Adding Solr document..."); AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = document; processor.processAdd(cmd); LOGGER.debug("Added Solr document"); } }
@Override public boolean upload(SolrInputDocument d) { try { AddUpdateCommand command = new AddUpdateCommand(req); command.solrDoc = d; command.commitWithin = commitWithin; processor.processAdd(command); } catch (Exception e) { log.warn("Error creating document : " + d, e); return false; } return true; }
/** * Adds the given document to the solr index without commit. * * @param docs the documents to add * @throws IOException iff something goes wrong */ public void add(Collection<SolrInputDocument> docs) throws IOException { for (SolrInputDocument doc : docs) { AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = doc; cmd.commitWithin = COMMIT_WITHIN; updateProcessor.processAdd(cmd); } }
/** * Builds a new {@link LocalGraph} with the given data. * * @param graphNode the graph name. * @param request the Solr query request. * @param response the Solr query response. * @param qparser the query parser. * @param fetchSize the fetch size that will be used in reads. * @param consumer the Graph event consumer that will be notified on relevant events. */ private LocalGraph( final Node graphNode, final SolrQueryRequest request, final SolrQueryResponse response, final QParser qparser, final int fetchSize, final GraphEventConsumer consumer) { super(graphNode, consumer, fetchSize); this.graphTermQuery = new TermQuery(new Term(Field.C, graphNodeStringified)); this.request = request; this.updateCommand = new AddUpdateCommand(request); this.updateProcessor = request.getCore().getUpdateProcessingChain(null).createProcessor(request, response); this.searcher = request.getSearcher(); this.qParser = qparser; }
private AddUpdateCommand getAddCommand(SolrParams params) { AddUpdateCommand addCmd = new AddUpdateCommand(); boolean overwrite = true; // the default Boolean overwritePending = null; Boolean overwriteCommitted = null; overwrite = params.getBool(UpdateParams.OVERWRITE, overwrite); addCmd.commitWithin = params.getInt(COMMIT_WITHIN, -1); // check if these flags are set if (overwritePending != null && overwriteCommitted != null) { if (overwritePending != overwriteCommitted) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "can't have different values for 'overwritePending' and 'overwriteCommitted'"); } overwrite = overwritePending; } addCmd.overwriteCommitted = overwrite; addCmd.overwritePending = overwrite; addCmd.allowDups = !overwrite; return addCmd; }
XmlUpdateRequestHandler.log.trace("SolrCore.update(add)"); addCmd = new AddUpdateCommand(); boolean overwrite = true; // the default
public ExtractingDocumentLoader(SolrQueryRequest req, UpdateRequestProcessor processor, TikaConfig config, SolrContentHandlerFactory factory) { this.params = req.getParams(); schema = req.getSchema(); this.config = config; this.processor = processor; templateAdd = new AddUpdateCommand(); templateAdd.allowDups = false; templateAdd.overwriteCommitted = true; templateAdd.overwritePending = true; if (params.getBool(UpdateParams.OVERWRITE, true)) { templateAdd.allowDups = false; templateAdd.overwriteCommitted = true; templateAdd.overwritePending = true; } else { templateAdd.allowDups = true; templateAdd.overwriteCommitted = false; templateAdd.overwritePending = false; } //this is lightweight autoDetectParser = new AutoDetectParser(config); this.factory = factory; }
public ExtractingDocumentLoader(SolrQueryRequest req, UpdateRequestProcessor processor, TikaConfig config, ParseContextConfig parseContextConfig, SolrContentHandlerFactory factory) { this.params = req.getParams(); this.core = req.getCore(); this.config = config; this.parseContextConfig = parseContextConfig; this.processor = processor; templateAdd = new AddUpdateCommand(req); templateAdd.overwrite = params.getBool(UpdateParams.OVERWRITE, true); templateAdd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1); //this is lightweight autoDetectParser = new AutoDetectParser(config); this.factory = factory; ignoreTikaException = params.getBool(ExtractingParams.IGNORE_TIKA_EXCEPTION, false); }
schema = req.getSchema(); templateAdd = new AddUpdateCommand(); templateAdd.allowDups=false; templateAdd.overwriteCommitted=true;
AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = docBuilder.getSolrInputDocument(); processor.processAdd(cmd);
/** * Runs a document through the specified chain, and returns the final * document used when the chain is completed (NOTE: some chains may * modify the document in place */ protected SolrInputDocument processAdd(final String chain, final SolrParams requestParams, final SolrInputDocument docIn) throws IOException { SolrCore core = h.getCore(); UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain); assertNotNull("No Chain named: " + chain, pc); SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = new LocalSolrQueryRequest(core, requestParams); try { SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp)); AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = docIn; UpdateRequestProcessor processor = pc.createProcessor(req, rsp); if (null != processor) { // test chain might be empty or short circuited. processor.processAdd(cmd); } return cmd.solrDoc; } finally { SolrRequestInfo.clearRequestInfo(); req.close(); } }
/** * Runs a document through the specified chain, and returns the final * document used when the chain is completed (NOTE: some chains may * modify the document in place */ protected SolrInputDocument processAdd(final String chain, final SolrParams requestParams, final SolrInputDocument docIn) throws IOException { SolrCore core = h.getCore(); UpdateRequestProcessorChain pc = core.getUpdateProcessingChain(chain); assertNotNull("No Chain named: " + chain, pc); SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = new LocalSolrQueryRequest(core, requestParams); try { AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = docIn; UpdateRequestProcessor processor = pc.createProcessor(req, rsp); processor.processAdd(cmd); return cmd.solrDoc; } finally { req.close(); } }
AddUpdateCommand cmd = new AddUpdateCommand(rb.req); cmd.setFlags(UpdateCommand.REPLAY); ulog.add(cmd, true);