Java Code Examples for org.apache.solr.client.solrj.embedded.EmbeddedSolrServer#close()
The following examples show how to use
org.apache.solr.client.solrj.embedded.EmbeddedSolrServer#close() .
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: ScienceIECorpusParser.java From jate with GNU Lesser General Public License v3.0 | 6 votes |
public static void main(String[] args) throws IOException, ParseException, JATEException { /*mergeGS("/home/zqz/Work/data/semeval2017-scienceie/scienceie2017_test/scienceie2017_test_gs", "/home/zqz/Work/data/semeval2017-scienceie/scienceie2017_test/all_key_phrases.txt");*/ Lemmatiser lem = new Lemmatiser(new EngLemmatiser(args[0], false, false)); String solrHomePath = args[4]; String solrCoreName = args[5]; final EmbeddedSolrServer solrServer = new EmbeddedSolrServer(Paths.get(solrHomePath), solrCoreName); JATEProperties jateProp = App.getJateProperties(args[6]); for (File f : new File(args[1]).listFiles()) { File outFolder = new File(args[2] + "/" + f.getName() + "/"); outFolder.mkdirs(); System.out.println(outFolder); transformToKEAOutput(f.toString(), 0, args[3], outFolder.toString(), lem, solrServer.getCoreContainer().getCore(solrCoreName), jateProp); } solrServer.close(); System.exit(0); }
Example 2
Source File: TestUtils.java From hbase-indexer with Apache License 2.0 | 6 votes |
public static void validateSolrServerDocumentCount(File solrHomeDir, FileSystem fs, Path outDir, int expectedDocs, int expectedShards) throws IOException, SolrServerException { long actualDocs = 0; int actualShards = 0; for (FileStatus dir : fs.listStatus(outDir)) { // for each shard if (dir.getPath().getName().startsWith("part") && dir.isDirectory()) { actualShards++; EmbeddedSolrServer solr = createEmbeddedSolrServer( solrHomeDir, fs, dir.getPath()); try { SolrQuery query = new SolrQuery(); query.setQuery("*:*"); QueryResponse resp = solr.query(query); long numDocs = resp.getResults().getNumFound(); actualDocs += numDocs; } finally { solr.close(); } } } assertEquals(expectedShards, actualShards); assertEquals(expectedDocs, actualDocs); }
Example 3
Source File: SystemService.java From DataHubSystem with GNU Affero General Public License v3.0 | 5 votes |
/** * Performs Solr restoration. * * @param properties properties containing arguments to execute the restoration. */ private static void restoreSolr5Index (Properties properties) throws IOException, SolrServerException { String solrHome = properties.getProperty ("dhus.solr.home"); String coreName = properties.getProperty ("dhus.solr.core.name"); final String name = properties.getProperty ("dhus.solr.backup.name"); final String location = properties.getProperty ( "dhus.solr.backup.location"); if (solrHome == null || coreName == null || name == null || location == null) { throw new UnsupportedOperationException (); } System.setProperty ("solr.solr.home", solrHome); CoreContainer core = new CoreContainer (solrHome); EmbeddedSolrServer server = new EmbeddedSolrServer (core, coreName); try { server.getCoreContainer ().load (); SolrQuery query = new SolrQuery(); query.setRequestHandler("/replication"); query.set("command", "restore"); query.set("name", name); query.set("location", location); server.query(query); LOGGER.info("SolR indexes restored."); } finally { server.close(); } }