List of usage examples for org.apache.solr.client.solrj.embedded EmbeddedSolrServer request
public final NamedList<Object> request(final SolrRequest request) throws SolrServerException, IOException
From source file:com.tripod.solr.util.EmbeddedSolrServerFactory.java
License:Apache License
/** * @param solrHome the Solr home directory to use * @param configSetHome the directory containing config sets * @param coreName the name of the core, must have a matching directory in configHome * @param cleanSolrHome if true the directory for solrHome will be deleted and re-created if it already exists * @return an EmbeddedSolrServer with a core created for the given coreName *//*from ww w . j av a2 s . c om*/ public static SolrClient create(final String solrHome, final String configSetHome, final String coreName, final boolean cleanSolrHome) throws IOException, SolrServerException { final File solrHomeDir = new File(solrHome); if (solrHomeDir.exists()) { FileUtils.deleteDirectory(solrHomeDir); solrHomeDir.mkdirs(); } else { solrHomeDir.mkdirs(); } final SolrResourceLoader loader = new SolrResourceLoader(solrHomeDir.toPath()); final Path configSetPath = Paths.get(configSetHome).toAbsolutePath(); final NodeConfig config = new NodeConfig.NodeConfigBuilder("embeddedSolrServerNode", loader) .setConfigSetBaseDirectory(configSetPath.toString()).build(); final EmbeddedSolrServer embeddedSolrServer = new EmbeddedSolrServer(config, coreName); final CoreAdminRequest.Create createRequest = new CoreAdminRequest.Create(); createRequest.setCoreName(coreName); createRequest.setConfigSet(coreName); embeddedSolrServer.request(createRequest); return embeddedSolrServer; }