org.apache.solr.update.processor.UpdateRequestProcessor Java Examples
The following examples show how to use
org.apache.solr.update.processor.UpdateRequestProcessor.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestNestedUpdateProcessor.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testDeeplyNestedURPSanity() throws Exception { SolrInputDocument docHierarchy = sdoc("id", "1", "children", sdocs(sdoc("id", "2", "name_s", "Yaz"), sdoc("id", "3", "name_s", "Jazz", "grandChild", sdoc("id", "4", "name_s", "Gaz"))), "lonelyChild", sdoc("id", "5", "name_s", "Loner")); UpdateRequestProcessor nestedUpdate = new NestedUpdateProcessorFactory().getInstance(req(), null, null); AddUpdateCommand cmd = new AddUpdateCommand(req()); cmd.solrDoc = docHierarchy; nestedUpdate.processAdd(cmd); cmd.clear(); @SuppressWarnings({"rawtypes"}) List children = (List) docHierarchy.get("children").getValues(); SolrInputDocument firstChild = (SolrInputDocument) children.get(0); assertEquals("SolrInputDocument(fields: [id=2, name_s=Yaz, _nest_path_=/children#0, _nest_parent_=1])", firstChild.toString()); SolrInputDocument secondChild = (SolrInputDocument) children.get(1); assertEquals("SolrInputDocument(fields: [id=3, name_s=Jazz, grandChild=SolrInputDocument(fields: [id=4, name_s=Gaz, _nest_path_=/children#1/grandChild#, _nest_parent_=3]), _nest_path_=/children#1, _nest_parent_=1])", secondChild.toString()); SolrInputDocument grandChild = (SolrInputDocument)((SolrInputDocument) children.get(1)).get("grandChild").getValue(); assertEquals("SolrInputDocument(fields: [id=4, name_s=Gaz, _nest_path_=/children#1/grandChild#, _nest_parent_=3])", grandChild.toString()); SolrInputDocument singularChild = (SolrInputDocument) docHierarchy.get("lonelyChild").getValue(); assertEquals("SolrInputDocument(fields: [id=5, name_s=Loner, _nest_path_=/lonelyChild#, _nest_parent_=1])", singularChild.toString()); }
Example #2
Source File: TestNestedUpdateProcessor.java From lucene-solr with Apache License 2.0 | 6 votes |
@Test public void testDeeplyNestedURPChildrenWoId() throws Exception { final String rootId = "1"; final String childKey = "grandChild"; final String expectedId = rootId + "/children#1/" + childKey + NUM_SEP_CHAR + SINGLE_VAL_CHAR; SolrInputDocument noIdChildren = sdoc("id", rootId, "children", sdocs(sdoc("name_s", "Yaz"), sdoc("name_s", "Jazz", childKey, sdoc("name_s", "Gaz")))); UpdateRequestProcessor nestedUpdate = new NestedUpdateProcessorFactory().getInstance(req(), null, null); AddUpdateCommand cmd = new AddUpdateCommand(req()); cmd.solrDoc = noIdChildren; nestedUpdate.processAdd(cmd); cmd.clear(); @SuppressWarnings({"rawtypes"}) List children = (List) noIdChildren.get("children").getValues(); SolrInputDocument idLessChild = (SolrInputDocument)((SolrInputDocument) children.get(1)).get(childKey).getValue(); assertTrue("Id less child did not get an Id", idLessChild.containsKey("id")); assertEquals("Id less child was assigned an unexpected id", expectedId, idLessChild.getFieldValue("id").toString()); }
Example #3
Source File: FileFloatSource.java From lucene-solr with Apache License 2.0 | 6 votes |
@Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { FileFloatSource.resetCache(); log.debug("readerCache has been reset."); UpdateRequestProcessor processor = req.getCore().getUpdateProcessingChain(null).createProcessor(req, rsp); try { RequestHandlerUtils.handleCommit(req, processor, req.getParams(), true); } finally { try { processor.finish(); } finally { processor.close(); } } }
Example #4
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
private void putAclTransactionState(UpdateRequestProcessor processor, SolrQueryRequest request, AclChangeSet changeSet) throws IOException { SolrDocument aclState = getState(core, request, "TRACKER!STATE!ACLTX"); String version = version(aclState, FIELD_S_ACLTXCOMMITTIME, FIELD_S_ACLTXID, changeSet.getCommitTimeMs(), changeSet.getId()); if (version != null) { SolrInputDocument input = new SolrInputDocument(); input.addField(FIELD_SOLR4_ID, "TRACKER!STATE!ACLTX"); input.addField(FIELD_VERSION, version); input.addField(FIELD_S_ACLTXID, changeSet.getId()); input.addField(FIELD_S_INACLTXID, changeSet.getId()); input.addField(FIELD_S_ACLTXCOMMITTIME, changeSet.getCommitTimeMs()); input.addField(FIELD_DOC_TYPE, DOC_TYPE_STATE); AddUpdateCommand cmd = new AddUpdateCommand(request); cmd.overwrite = true; cmd.solrDoc = input; processor.processAdd(cmd); } }
Example #5
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
private void deleteByQuery(String query) throws IOException { UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); DeleteUpdateCommand delDocCmd = new DeleteUpdateCommand(request); delDocCmd.setQuery(query); processor.processDelete(delDocCmd); } finally { if (processor != null) { processor.finish(); } } }
Example #6
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
private void putTransactionState(UpdateRequestProcessor processor, SolrQueryRequest request, Transaction tx) throws IOException { SolrDocument txState = getState(core, request, "TRACKER!STATE!TX"); String version = version(txState, FIELD_S_TXCOMMITTIME, FIELD_S_TXID, tx.getCommitTimeMs(), tx.getId()); if (version != null) { SolrInputDocument input = new SolrInputDocument(); input.addField(FIELD_SOLR4_ID, "TRACKER!STATE!TX"); input.addField(FIELD_VERSION, version); input.addField(FIELD_S_TXID, tx.getId()); input.addField(FIELD_S_INTXID, tx.getId()); input.addField(FIELD_S_TXCOMMITTIME, tx.getCommitTimeMs()); input.addField(FIELD_DOC_TYPE, DOC_TYPE_STATE); AddUpdateCommand cmd = new AddUpdateCommand(request); cmd.overwrite = true; cmd.solrDoc = input; processor.processAdd(cmd); } }
Example #7
Source File: ExtractingDocumentLoader.java From lucene-solr with Apache License 2.0 | 6 votes |
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); }
Example #8
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void capIndex(long dbid) throws IOException { UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); SolrInputDocument input = new SolrInputDocument(); input.addField(FIELD_SOLR4_ID, INDEX_CAP_ID); input.addField(FIELD_VERSION, 0); input.addField(FIELD_DBID, -dbid); //Making this negative to ensure it is never confused with node DBID input.addField(FIELD_DOC_TYPE, DOC_TYPE_STATE); AddUpdateCommand cmd = new AddUpdateCommand(request); cmd.overwrite = true; cmd.solrDoc = input; processor.processAdd(cmd); } finally { if (processor != null) processor.finish(); } }
Example #9
Source File: ChronixRetentionHandler.java From chronix.server with Apache License 2.0 | 5 votes |
/** * Processes the request for the round robin update update handler. * * @param req - the solr query request information * @param rsp - the solr query response information * @throws ParseException,IOException,SyntaxError - if bad things happen */ @Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws ParseException, IOException, SyntaxError { String deletionQuery = getDeletionQuery(); LOGGER.info("Handle deletion request for query {}", deletionQuery); if (olderDocumentsExists(deletionQuery, req, rsp)) { UpdateRequestProcessor processor = getProcessor(req, rsp); deleteOldDocuments(deletionQuery, processor, req); commitDeletions(processor, req); } }
Example #10
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void updateTransaction(Transaction txn) throws IOException { canUpdate(); UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); AddUpdateCommand cmd = new AddUpdateCommand(request); cmd.overwrite = true; SolrInputDocument input = new SolrInputDocument(); input.addField(FIELD_SOLR4_ID, AlfrescoSolrDataModel.getTransactionDocumentId(txn.getId())); input.addField(FIELD_VERSION, 1); input.addField(FIELD_TXID, txn.getId()); input.addField(FIELD_INTXID, txn.getId()); input.addField(FIELD_TXCOMMITTIME, txn.getCommitTimeMs()); input.addField(FIELD_DOC_TYPE, DOC_TYPE_TX); if (cascadeTrackingEnabled()) { input.addField(FIELD_CASCADE_FLAG, 0); } cmd.solrDoc = input; processor.processAdd(cmd); } finally { if (processor != null) { processor.finish(); } } }
Example #11
Source File: AbstractIngestionHandler.java From chronix.server with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { formatResponseAsJson(req); if (req.getContentStreams() == null) { LOGGER.warn("no content stream"); rsp.add("error", "No content stream"); return; } boolean commit = Boolean.parseBoolean(req.getParams().get("commit", "true")); InputStream stream = req.getContentStreams().iterator().next().getStream(); stream = detectGzip(stream); MetricTimeSeriesConverter converter = new MetricTimeSeriesConverter(); UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessorChain(req.getParams()); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); try { for (MetricTimeSeries series : formatParser.parse(stream)) { SolrInputDocument document = new SolrInputDocument(); converter.to(series).getFields().forEach(document::addField); storeDocument(document, processor, req); } if (commit) { LOGGER.debug("Committing transaction..."); processor.processCommit(new CommitUpdateCommand(req, false)); LOGGER.debug("Committed transaction"); } else { LOGGER.debug("Only adding documents."); } } finally { processor.finish(); } }
Example #12
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void hardCommit() throws IOException { // avoid multiple commits and warming searchers commitAndRollbackLock.writeLock().lock(); try { UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); CommitUpdateCommand commitUpdateCommand = new CommitUpdateCommand(request, false); commitUpdateCommand.openSearcher = false; commitUpdateCommand.softCommit = false; commitUpdateCommand.waitSearcher = false; processor.processCommit(commitUpdateCommand); } finally { if (processor != null) { processor.finish(); } } } finally { commitAndRollbackLock.writeLock().unlock(); } }
Example #13
Source File: AbstractIngestionHandler.java From chronix.server with Apache License 2.0 | 5 votes |
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"); }
Example #14
Source File: RdfBulkUpdateRequestHandler.java From SolRDF with Apache License 2.0 | 5 votes |
@Override public void load( final SolrQueryRequest request, final SolrQueryResponse response, final ContentStream stream, final UpdateRequestProcessor processor) throws Exception { final PipedRDFIterator<Quad> iterator = new PipedRDFIterator<Quad>(); final StreamRDF inputStream = new PipedQuadsStream(iterator); executor.submit(new Runnable() { @Override public void run() { try { RDFDataMgr.parse( inputStream, stream.getStream(), RDFLanguages.contentTypeToLang(stream.getContentType())); } catch (final IOException exception) { throw new SolrException(ErrorCode.SERVER_ERROR, exception); } } }); final DatasetGraph dataset = new LocalDatasetGraph(request, response); while (iterator.hasNext()) { dataset.add(iterator.next()); } }
Example #15
Source File: RdfBulkUpdateRequestHandler.java From SolRDF with Apache License 2.0 | 5 votes |
@Override public void load( final SolrQueryRequest request, final SolrQueryResponse response, final ContentStream stream, final UpdateRequestProcessor processor) throws Exception { final PipedRDFIterator<Triple> iterator = new PipedRDFIterator<Triple>(); final StreamRDF inputStream = new PipedTriplesStream(iterator); executor.submit(new Runnable() { @Override public void run() { try { RDFDataMgr.parse( inputStream, stream.getStream(), RDFLanguages.contentTypeToLang(stream.getContentType())); } catch (final IOException exception) { throw new SolrException(ErrorCode.SERVER_ERROR, exception); } } }); // Graph Store Protocol indicates the target graph URI separately. // So the incoming Content-type here is one that maps "Triples Loader" but // the indexed tuple could be a Quad. final String graphUri = request.getParams().get(Names.GRAPH_URI_ATTRIBUTE_NAME); final DatasetGraph dataset = new LocalDatasetGraph(request, response, null, null); final Graph defaultGraph = graphUri == null ? dataset.getDefaultGraph() : dataset.getGraph(NodeFactory.createURI(graphUri)); while (iterator.hasNext()) { defaultGraph.add(iterator.next()); } }
Example #16
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
/** * Index information of a node that does not belong to the current shard. * These information are necessary for cascade tracker to work properly. * The information stored are: * nodeDocumentId, cascadeTx */ private void indexNonShardCascade(NodeMetaData nodeMetaData) throws IOException { UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); StringPropertyValue stringPropertyValue = (StringPropertyValue) nodeMetaData.getProperties().get(ContentModel.PROP_CASCADE_TX); List<FieldInstance> fieldInstances = AlfrescoSolrDataModel.getInstance().getIndexedFieldNamesForProperty(ContentModel.PROP_CASCADE_TX).getFields(); FieldInstance fieldInstance = fieldInstances.get(0); AddUpdateCommand cmd = new AddUpdateCommand(request); SolrInputDocument input = new SolrInputDocument(); input.addField(FIELD_SOLR4_ID, AlfrescoSolrDataModel.getNodeDocumentId(nodeMetaData.getTenantDomain(), nodeMetaData.getId())); input.addField(FIELD_VERSION, 0); input.addField(fieldInstance.getField(), stringPropertyValue.getValue()); cmd.solrDoc = input; processor.processAdd(cmd); } finally { if (processor != null) { processor.finish(); } } }
Example #17
Source File: AddCoordinatesUpdateRequestProcessor.java From apache-solr-essentials with Apache License 2.0 | 5 votes |
/** * Builds a new {@link UpdateRequestProcessor} with the given data. * * @param service the geolocation service provider. * @param sleepTimeInMsecs the pause time between each geolocation request. */ public AddCoordinatesUpdateRequestProcessor( final GoogleGeoLocationService service, final int sleepTimeInMsecs, final UpdateRequestProcessor next) { super(next); this.sleepTimeInMsecs = sleepTimeInMsecs; this.service = service; }
Example #18
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void indexAclTransaction(AclChangeSet changeSet, boolean overwrite) throws IOException { canUpdate(); UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); SolrInputDocument aclTx = new SolrInputDocument(); aclTx.addField(FIELD_SOLR4_ID, getAclChangeSetDocumentId(changeSet.getId())); aclTx.addField(FIELD_VERSION, "0"); aclTx.addField(FIELD_ACLTXID, changeSet.getId()); aclTx.addField(FIELD_INACLTXID, changeSet.getId()); aclTx.addField(FIELD_ACLTXCOMMITTIME, changeSet.getCommitTimeMs()); aclTx.addField(FIELD_DOC_TYPE, DOC_TYPE_ACL_TX); AddUpdateCommand cmd = new AddUpdateCommand(request); cmd.overwrite = overwrite; cmd.solrDoc = aclTx; processor.processAdd(cmd); putAclTransactionState(processor, request, changeSet); } finally { if (processor != null) processor.finish(); } }
Example #19
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void rollback() throws IOException { commitAndRollbackLock.writeLock().lock(); try { activeTrackerThreadsLock.writeLock().lock(); try { activeTrackerThreads.clear(); UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); processor.processRollback(new RollbackUpdateCommand(request)); } finally { if (processor != null) { processor.finish(); } } } finally { activeTrackerThreadsLock.writeLock().unlock(); } } finally { commitAndRollbackLock.writeLock().unlock(); } }
Example #20
Source File: MtasUpdateRequestProcessorFactory.java From mtas with Apache License 2.0 | 5 votes |
@Override public UpdateRequestProcessor getInstance(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor next) { try { init(req); } catch (IOException e) { log.error(e); } return new MtasUpdateRequestProcessor(next, config); }
Example #21
Source File: JsonLoader.java From lucene-solr with Apache License 2.0 | 5 votes |
SingleThreadedJsonLoader(SolrQueryRequest req, SolrQueryResponse rsp, UpdateRequestProcessor processor) { this.processor = processor; this.req = req; this.rsp = rsp; commitWithin = req.getParams().getInt(UpdateParams.COMMIT_WITHIN, -1); overwrite = req.getParams().getBool(UpdateParams.OVERWRITE, true); }
Example #22
Source File: TestSchemalessBufferedUpdates.java From lucene-solr with Apache License 2.0 | 5 votes |
private SolrInputDocument processAdd(final SolrInputDocument docIn) throws IOException { UpdateRequestProcessorChain processorChain = h.getCore().getUpdateProcessingChain(UPDATE_CHAIN); assertNotNull("Undefined URP chain '" + UPDATE_CHAIN + "'", processorChain); List <UpdateRequestProcessorFactory> factoriesUpToDUP = new ArrayList<>(); for (UpdateRequestProcessorFactory urpFactory : processorChain.getProcessors()) { factoriesUpToDUP.add(urpFactory); if (urpFactory.getClass().equals(DistributedUpdateProcessorFactory.class)) break; } UpdateRequestProcessorChain chainUpToDUP = new UpdateRequestProcessorChain(factoriesUpToDUP, h.getCore()); assertNotNull("URP chain '" + UPDATE_CHAIN + "'", chainUpToDUP); SolrQueryResponse rsp = new SolrQueryResponse(); SolrQueryRequest req = req(); try { SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp)); AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = docIn; UpdateRequestProcessor processor = chainUpToDUP.createProcessor(req, rsp); processor.processAdd(cmd); if (cmd.solrDoc.get("f_dt").getValue() instanceof Date) { // Non-JSON types (Date in this case) aren't handled properly in noggit-0.6. Although this is fixed in // https://github.com/yonik/noggit/commit/ec3e732af7c9425e8f40297463cbe294154682b1 to call obj.toString(), // Date::toString produces a Date representation that Solr doesn't like, so we convert using Instant::toString cmd.solrDoc.get("f_dt").setValue(((Date) cmd.solrDoc.get("f_dt").getValue()).toInstant().toString()); } return cmd.solrDoc; } finally { SolrRequestInfo.clearRequestInfo(); req.close(); } }
Example #23
Source File: JavabinLoader.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream, UpdateRequestProcessor processor) throws Exception { InputStream is = null; try { is = stream.getStream(); parseAndLoadDocs(req, rsp, is, processor); } finally { if(is != null) { is.close(); } } }
Example #24
Source File: JavabinLoader.java From lucene-solr with Apache License 2.0 | 5 votes |
private void handleMultiStream(SolrQueryRequest req, SolrQueryResponse rsp, InputStream stream, UpdateRequestProcessor processor) throws IOException { FastInputStream in = FastInputStream.wrap(stream); SolrParams old = req.getParams(); try (JavaBinCodec jbc = new JavaBinCodec() { SolrParams params; AddUpdateCommand addCmd = null; @Override public List<Object> readIterator(DataInputInputStream fis) throws IOException { while (true) { Object o = readVal(fis); if (o == END_OBJ) break; if (o instanceof NamedList) { params = ((NamedList) o).toSolrParams(); } else { try { if (o instanceof byte[]) { if (params != null) req.setParams(params); byte[] buf = (byte[]) o; contentStreamLoader.load(req, rsp, new ContentStreamBase.ByteArrayStream(buf, null), processor); } else { throw new RuntimeException("unsupported type "); } } catch (Exception e) { throw new RuntimeException(e); } finally { params = null; req.setParams(old); } } } return Collections.emptyList(); } }) { jbc.unmarshal(in); } }
Example #25
Source File: JavabinLoader.java From lucene-solr with Apache License 2.0 | 5 votes |
private void delete(SolrQueryRequest req, UpdateRequest update, UpdateRequestProcessor processor) throws IOException { SolrParams params = update.getParams(); DeleteUpdateCommand delcmd = new DeleteUpdateCommand(req); if(params != null) { delcmd.commitWithin = params.getInt(UpdateParams.COMMIT_WITHIN, -1); } if(update.getDeleteByIdMap() != null) { Set<Entry<String,Map<String,Object>>> entries = update.getDeleteByIdMap().entrySet(); for (Entry<String,Map<String,Object>> e : entries) { delcmd.id = e.getKey(); Map<String,Object> map = e.getValue(); if (map != null) { Long version = (Long) map.get("ver"); if (version != null) { delcmd.setVersion(version); } } if (map != null) { String route = (String) map.get(ShardParams._ROUTE_); if (route != null) { delcmd.setRoute(route); } } processor.processDelete(delcmd); delcmd.clear(); } } if(update.getDeleteQuery() != null) { for (String s : update.getDeleteQuery()) { delcmd.query = s; processor.processDelete(delcmd); } } }
Example #26
Source File: ContentStreamHandlerBase.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void handleRequestBody(SolrQueryRequest req, SolrQueryResponse rsp) throws Exception { SolrParams params = req.getParams(); UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessorChain(params); UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp); try { ContentStreamLoader documentLoader = newLoader(req, processor); Iterable<ContentStream> streams = req.getContentStreams(); if (streams == null) { if (!RequestHandlerUtils.handleCommit(req, processor, params, false) && !RequestHandlerUtils.handleRollback(req, processor, params, false)) { throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "missing content stream"); } } else { for (ContentStream stream : streams) { documentLoader.load(req, rsp, stream, processor); } // Perhaps commit from the parameters RequestHandlerUtils.handleCommit(req, processor, params, false); RequestHandlerUtils.handleRollback(req, processor, params, false); } } finally { // finish the request try { processor.finish(); } finally { processor.close(); } } }
Example #27
Source File: UpdateRequestHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
@Override public void load(SolrQueryRequest req, SolrQueryResponse rsp, ContentStream stream, UpdateRequestProcessor processor) throws Exception { ContentStreamLoader loader = pathVsLoaders.get(req.getContext().get(PATH)); if(loader == null) { String type = req.getParams().get(UpdateParams.ASSUME_CONTENT_TYPE); if (type == null) { type = stream.getContentType(); } if (type == null) { // Normal requests will not get here. throw new SolrException(ErrorCode.UNSUPPORTED_MEDIA_TYPE, "Missing ContentType"); } int idx = type.indexOf(';'); if (idx > 0) { type = type.substring(0, idx); } loader = loaders.get(type); if (loader == null) { throw new SolrException(ErrorCode.UNSUPPORTED_MEDIA_TYPE, "Unsupported ContentType: " + type + " Not in: " + loaders.keySet()); } } if(loader.getDefaultWT()!=null) { setDefaultWT(req,loader); } loader.load(req, rsp, stream, processor); }
Example #28
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void commit() throws IOException { // avoid multiple commits and warming searchers commitAndRollbackLock.writeLock().lock(); try { canUpdate(); UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); processor.processCommit(new CommitUpdateCommand(request, false)); } finally { if (processor != null) { processor.finish(); } } } finally { commitAndRollbackLock.writeLock().unlock(); } }
Example #29
Source File: BlobHandler.java From lucene-solr with Apache License 2.0 | 5 votes |
public static void indexMap(SolrQueryRequest req, SolrQueryResponse rsp, Map<String, Object> doc) throws IOException { SolrInputDocument solrDoc = new SolrInputDocument(); for (Map.Entry<String, Object> e : doc.entrySet()) solrDoc.addField(e.getKey(), e.getValue()); UpdateRequestProcessorChain processorChain = req.getCore().getUpdateProcessorChain(req.getParams()); try (UpdateRequestProcessor processor = processorChain.createProcessor(req, rsp)) { AddUpdateCommand cmd = new AddUpdateCommand(req); cmd.solrDoc = solrDoc; log.info("Adding doc: {}", doc); processor.processAdd(cmd); log.info("committing doc: {}", doc); processor.processCommit(new CommitUpdateCommand(req, false)); processor.finish(); } }
Example #30
Source File: SolrInformationServer.java From SearchServices with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void cascadeNodes(List<NodeMetaData> nodeMetaDatas, boolean overwrite) throws IOException, JSONException { UpdateRequestProcessor processor = null; try (SolrQueryRequest request = newSolrQueryRequest()) { processor = this.core.getUpdateProcessingChain(null).createProcessor(request, newSolrQueryResponse()); for (NodeMetaData nodeMetaData : nodeMetaDatas) { if (mayHaveChildren(nodeMetaData)) { cascadeUpdateV2(nodeMetaData, overwrite, request, processor); } } } catch (Exception exception) { LOGGER.error("Exception while processing cascading updates from the parent nodes. " + "See the stacktrace below for further details.", exception); } finally { if (processor != null) { processor.finish(); } } }