List of usage examples for org.apache.solr.client.solrj SolrClient request
public final NamedList<Object> request(final SolrRequest request) throws SolrServerException, IOException
From source file:com.stratio.decision.service.SolrOperationsService.java
License:Apache License
public void createCore(StratioStreamingMessage message) throws IOException, URISyntaxException, SolrServerException, ParserConfigurationException, SAXException, TransformerException, InterruptedException { String core = message.getStreamName(); String dataPath = this.dataDir + '/' + core + "/data"; String confPath = this.dataDir + '/' + core + "/conf"; createDirs(dataPath, confPath);// www . j ava2 s . c o m createSolrConfig(confPath); createSolrSchema(message.getColumns(), confPath); SolrClient solrClient = getSolrclient(core); CoreAdminRequest.Create createCore = new CoreAdminRequest.Create(); createCore.setDataDir(dataPath); createCore.setInstanceDir(dataDir + '/' + core); createCore.setCoreName(core); createCore.setSchemaName("schema.xml"); createCore.setConfigName("solrconfig.xml"); if (solrClient instanceof CloudSolrClient) { ((CloudSolrClient) solrClient).uploadConfig(Paths.get(confPath), core); } solrClient.request(createCore); }
From source file:net.semanticmetadata.lire.solr.indexing.ParallelSolrIndexer.java
License:Open Source License
private void postIndexToServer() { try {// w ww . j a va 2 s. c om SolrClient client = new HttpSolrClient.Builder( "http://54.93.254.52:8983/solr/" + gender + "_" + category).build(); //SolrClient client = new HttpSolrClient.Builder("http://54.93.254.52:8983/solr/prueba").build(); DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance(); DocumentBuilder docBuilder = dbfac.newDocumentBuilder(); Document doc = docBuilder.parse(outfile); TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); String xmlOutput = writer.getBuffer().toString().replaceAll("[\n\r]", ""); DirectXmlRequest xmlreq = new DirectXmlRequest("/update", xmlOutput); client.request(xmlreq); client.commit(); } catch (SolrServerException | IOException | TransformerException | SAXException | ParserConfigurationException e) { e.printStackTrace(); } }