/** * 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; }
/** * Gets the processor build from the processor update chain(UpdateParams.UPDATE_CHAIN) * * @param req - the solr query request information * @param rsp - the solr query response information * @return the update request processor */ private UpdateRequestProcessor getProcessor(SolrQueryRequest req, SolrQueryResponse rsp) { UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessingChain(req.getParams().get(UpdateParams.UPDATE_CHAIN)); return processorChain.createProcessor(req, rsp); }
private void writeToCloud (SolrInputDocument solrDoc, String uri) { ArrayList<String> urls = xqueryComponent.getShardURLs(true); LoggerFactory.getLogger(getClass()).debug ("writing " + uri + " to cloud at " + urls); SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = UpdateDocCommand.makeSolrRequest(core); ((ModifiableSolrParams)req.getParams()).add(ShardParams.SHARDS, urls.toArray(new String[urls.size()])); UpdateRequest updateReq = new UpdateRequest(); updateReq.add(solrDoc); UpdateDocCommand cmd = new UpdateDocCommand(req, solrDoc, null, uri); UpdateRequestProcessorChain updateChain = xqueryComponent.getCore().getUpdateProcessingChain("lux-update-chain"); try { UpdateRequestProcessor processor = updateChain.createProcessor(req, rsp); processor.processAdd(cmd); processor.finish(); } catch (IOException e) { throw new LuxException (e); } }
UpdateRequestProcessorChain processorFactory = core.getUpdateProcessingChain(null);
protected void doCommit () { boolean isCloud = shards != null && shards.length > 1; SolrQueryRequest req = new SolrQueryRequestBase (core, new ModifiableSolrParams()) {}; CommitUpdateCommand cmd = new CommitUpdateCommand(req, false); cmd.softCommit = true; // cmd.expungeDeletes = false; // cmd.waitFlush = true; // cmd.waitSearcher = true; LoggerFactory.getLogger(getClass()).debug ("commit {}", shards); try { if (isCloud) { SolrQueryResponse rsp = new SolrQueryResponse(); // ((ModifiableSolrParams)req.getParams()).add(ShardParams.SHARDS, getShardURLs(false)); UpdateRequestProcessorChain updateChain = core.getUpdateProcessingChain("lux-update-chain"); updateChain.createProcessor(req, rsp).processCommit(cmd); } else { // commit locally core.getUpdateHandler().commit(cmd); } } catch (IOException e) { throw new LuxException(e); } }
private void deleteCloud (DeleteUpdateCommand cmd) throws IOException { UpdateRequestProcessorChain updateChain = xqueryComponent.getCore().getUpdateProcessingChain("lux-update-chain"); SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = UpdateDocCommand.makeSolrRequest(core); UpdateRequestProcessor processor = updateChain.createProcessor(req, rsp); processor.processDelete(cmd); processor.finish(); }
protected void finish(final String chain) 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, new ModifiableSolrParams()); UpdateRequestProcessor processor = pc.createProcessor(req, rsp); try { processor.finish(); } finally { IOUtils.closeQuietly(processor); req.close(); } }
protected void processCommit(final String chain) 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, new ModifiableSolrParams()); CommitUpdateCommand cmd = new CommitUpdateCommand(req,false); UpdateRequestProcessor processor = pc.createProcessor(req, rsp); try { processor.processCommit(cmd); } finally { req.close(); } }
protected void processDeleteById(final String chain, String id) 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, new ModifiableSolrParams()); DeleteUpdateCommand cmd = new DeleteUpdateCommand(req); cmd.setId(id); UpdateRequestProcessor processor = pc.createProcessor(req, rsp); try { processor.processDelete(cmd); } finally { 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 { 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(); } }
public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { SolrParams params = req.getParams(); UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR)); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); try { ContentStreamLoader documentLoader = newLoader(req, processor); Iterable<ContentStream> streams = req.getContentStreams(); if (streams == null) { if (!RequestHandlerUtils.handleCommit(processor, params, false) && !RequestHandlerUtils.handleRollback(processor, params, false)) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing content stream"); } } else { for (ContentStream stream : streams) { documentLoader.load(req, rsp, stream); } // Perhaps commit from the parameters RequestHandlerUtils.handleCommit(processor, params, false); RequestHandlerUtils.handleRollback(processor, params, false); } } finally { // finish the request processor.finish(); } }
protected boolean handleMergeAction(SolrQueryRequest req, SolrQueryResponse rsp) throws IOException { boolean doPersist = false; SolrParams params = req.getParams(); SolrParams required = params.required(); String cname = required.get(CoreAdminParams.CORE); SolrCore core = coreContainer.getCore(cname); if (core != null) { try { doPersist = coreContainer.isPersistent(); String[] dirNames = required.getParams(CoreAdminParams.INDEX_DIR); DirectoryFactory dirFactory = core.getDirectoryFactory(); Directory[] dirs = new Directory[dirNames.length]; for (int i = 0; i < dirNames.length; i++) { dirs[i] = dirFactory.open(dirNames[i]); } UpdateRequestProcessorChain processorChain = core.getUpdateProcessingChain(params.get(UpdateParams.UPDATE_PROCESSOR)); SolrQueryRequest wrappedReq = new LocalSolrQueryRequest(core, req.getParams()); UpdateRequestProcessor processor = processorChain.createProcessor(wrappedReq, rsp); processor.processMergeIndexes(new MergeIndexesCommand(dirs)); } finally { core.close(); } } return doPersist; }
/** * 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(); } }
json = "{\"description\": \""+tooLongValue+"\"}"; SirenFacetProcessorFactory factory = (SirenFacetProcessorFactory)h.getCore().getUpdateProcessingChain("generate-facets-processor").getFactories()[0]; TypeMapping stringTypeMapping = factory.getTypeMappingValueClass(FacetDatatype.STRING.xsdDatatype); assertTrue("Bad test. Test value has to be longer than maxFieldSize for TypeMapping of string = " +