@Override public void process(final InputStream in) throws IOException { ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(contentStreamPath); request.setParams(new ModifiableSolrParams()); String paramName = paramNames.next(); for (String paramValue : requestParams.getParams(paramName)) { request.getParams().add(paramName, paramValue); request.setParam(COLLECTION_PARAM_NAME, collection); request.setParam(COMMIT_WITHIN_PARAM_NAME, commitWithin.toString()); request.setBasicAuthCredentials(getUsername(), getPassword()); request.addContentStream(new ContentStreamBase() { @Override public InputStream getStream() throws IOException { UpdateResponse response = request.process(getSolrClient()); getLogger().debug("Got {} response from Solr", new Object[]{response.getStatus()}); } catch (SolrException e) {
private SolrRequest createtSolrRequest(String json) { final ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(jsonUpdateUrl); final ContentStream cs = new ContentStreamBase.StringStream(json, CONTENT_TYPE); request.addContentStream(cs); if (logger.isDebugEnabled()) { logger.debug("Request generated with JSON: " + json); } return request; }
ContentStreamUpdateRequest contentStreamUpdateRequest = new ContentStreamUpdateRequest("/update/csv"); contentStreamUpdateRequest.setParam("skip", "_version_"); for (String mvField : multivaluedFields) { contentStreamUpdateRequest.setParam("f." + mvField + ".split", "true"); contentStreamUpdateRequest.setParam("f." + mvField + ".separator", MULTIPLE_VALUES_SPLITTER); contentStreamUpdateRequest.setParam("stream.contentType", "text/csv;charset=utf-8"); contentStreamUpdateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); contentStreamUpdateRequest.addFile(file, "text/csv;charset=utf-8");
if (getSolr() != null) { if (streams != null && !streams.isEmpty()) { ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract"); req.addContentStream(streams); req.setParams(params); req.setParam(ExtractingParams.UNKNOWN_FIELD_PREFIX, "attr_"); req.setParam(ExtractingParams.MAP_PREFIX + "content", "fulltext"); req.setParam(ExtractingParams.EXTRACT_FORMAT, "text"); req.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); req.process(getSolr()); } else { getSolr().add(doc);
private ContentStreamUpdateRequest updateRequest(HtmlResource htmlFile) { try { ContentStreamUpdateRequest updateRequest = new ContentStreamUpdateRequest(configurationProperties.getExtractPath()); updateRequest.addContentStream(new ContentStreamBase.StringStream(htmlFile.getHtml(), "text/html;charset=UTF-8")); updateRequest.setParam(FILE_ID_LITERAL, htmlFile.getResource().getFile().getAbsolutePath()); updateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); return updateRequest; } catch (IOException ex) { throw new SolrItemWriterException("Could not retrieve filename", ex); } }
SolrServer server = new CommonsHttpSolrServer("http://localhost:8983/solr"); ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract"); req.addFile(new File("myxml.xml")); req.setParam(ExtractingParams.EXTRACT_ONLY, "true"); NamedList<Object> result = server.request(req); System.out.println("Result: " + result);
ContentStreamUpdateRequest updateRequest = new ContentStreamUpdateRequest(getRequestHandler()); updateRequest.addFile((File) body, mimeType); updateRequest.setParam(paramName, entry.getValue().toString()); updateRequest.process(solrServer); } else { MimetypesFileTypeMap mimeTypesMap = new MimetypesFileTypeMap(); String mimeType = mimeTypesMap.getContentType((File) body); ContentStreamUpdateRequest updateRequest = new ContentStreamUpdateRequest(getRequestHandler()); updateRequest.addFile((File) body, mimeType); updateRequest.setParam(paramName, entry.getValue().toString()); updateRequest.process(solrServer);
SolrClient server = new HttpSolrClient("http://localhost:8983/solr/my_collection"); ContentStreamUpdateRequest req = new ContentStreamUpdateRequest("/update/extract"); req.addFile(new File("my-file.pdf")); server.request(req);
/** * Add a File to the {@link org.apache.solr.common.util.ContentStream}s. * @param file The File to add. * @throws IOException if there was an error with the file. * * @see #getContentStreams() * @see org.apache.solr.common.util.ContentStreamBase.FileStream */ public void addFile(File file) throws IOException { addContentStream(new ContentStreamBase.FileStream(file)); }
private void request(ContentStreamUpdateRequest updateRequest) { try { solrClient.request(updateRequest, MarkdownDocument.MARKDOWN_CORE); logger.info("Updated document in Solr: {}", updateRequest.getParams().get(FILE_ID_LITERAL)); } catch (SolrServerException | IOException ex) { throw new SolrItemWriterException("Could not index document", ex); } } }
ContentStreamUpdateRequest contentStreamUpdateRequest = new ContentStreamUpdateRequest("/update/csv"); contentStreamUpdateRequest.setParam("stream.contentType", "text/plain;charset=utf-8"); contentStreamUpdateRequest.setParam("escape", "\\"); contentStreamUpdateRequest.setParam("skip", "_version_"); contentStreamUpdateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); contentStreamUpdateRequest.addFile(tempCsv, "text/plain;charset=utf-8"); contentStreamUpdateRequest.setParam("f." + multivaluedField + ".split", Boolean.TRUE.toString()); contentStreamUpdateRequest .setParam("f." + multivaluedField + ".separator", MULTIPLE_VALUES_SPLITTER);
private SolrRequest<UpdateResponse> createSolrRequest(String json) { final ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(jsonUpdateUrl); final ContentStream cs = new ContentStreamBase.StringStream(json, CONTENT_TYPE); request.addContentStream(cs); LOG.debug("Request generated with JSON: {}", json); return request; } }
/** * Add a File to the {@link org.apache.solr.common.util.ContentStream}s. * @param file The File to add. * @throws IOException if there was an error with the file. * * @see #getContentStreams() * @see org.apache.solr.common.util.ContentStreamBase.FileStream */ public void addFile(File file, String contentType) throws IOException { ContentStreamBase cs = new ContentStreamBase.FileStream(file); cs.setContentType(contentType); addContentStream(cs); }
@Override public void process(final InputStream in) throws IOException { ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(contentStreamPath); request.setParams(new ModifiableSolrParams()); String paramName = paramNames.next(); for (String paramValue : requestParams.getParams(paramName)) { request.getParams().add(paramName, paramValue); request.setParam(COLLECTION_PARAM_NAME, collection); request.setParam(COMMIT_WITHIN_PARAM_NAME, commitWithin.toString()); request.setBasicAuthCredentials(getUsername(), getPassword()); request.addContentStream(new ContentStreamBase() { @Override public InputStream getStream() throws IOException { UpdateResponse response = request.process(getSolrClient()); getLogger().debug("Got {} response from Solr", new Object[]{response.getStatus()}); } catch (SolrException e) {
ContentStreamUpdateRequest contentStreamUpdateRequest = new ContentStreamUpdateRequest("/update/csv"); contentStreamUpdateRequest.setParam("stream.contentType", "text/plain;charset=utf-8"); contentStreamUpdateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); contentStreamUpdateRequest.addFile(tempCsv, "text/plain;charset=utf-8");
private SolrRequest createtSolrRequest(String json) { final ContentStreamUpdateRequest request = new ContentStreamUpdateRequest(jsonUpdateUrl); final ContentStream cs = new ContentStreamBase.StringStream(json, CONTENT_TYPE); request.addContentStream(cs); if (logger.isDebugEnabled()) { logger.debug("Request generated with JSON: " + json); } return request; }
/** * Add a File to the {@link org.apache.solr.common.util.ContentStream}s. * @param file The File to add. * @throws IOException if there was an error with the file. * * @see #getContentStreams() * @see org.apache.solr.common.util.ContentStreamBase.FileStream */ public void addFile(File file, String contentType) throws IOException { ContentStreamBase cs = new ContentStreamBase.FileStream(file); cs.setContentType(contentType); addContentStream(cs); }
ContentStreamUpdateRequest contentStreamUpdateRequest = new ContentStreamUpdateRequest("/update/csv"); contentStreamUpdateRequest.setParam("stream.contentType", "text/plain;charset=utf-8"); contentStreamUpdateRequest.setAction(AbstractUpdateRequest.ACTION.COMMIT, true, true); contentStreamUpdateRequest.addFile(tempCsv);