List of usage examples for org.apache.solr.client.solrj.request CollectionAdminRequest listCollections
public static java.util.List<String> listCollections(SolrClient client) throws IOException, SolrServerException
From source file:org.apache.metron.solr.dao.SolrSearchDao.java
License:Apache License
private String getCollections(List<String> indices) throws IOException, SolrServerException { List<String> existingCollections = CollectionAdminRequest.listCollections(client); return indices.stream().filter(existingCollections::contains).collect(Collectors.joining(",")); }
From source file:org.apache.metron.solr.dao.SolrSearchDaoTest.java
License:Apache License
@SuppressWarnings("unchecked") @Before//from ww w .j ava 2 s. c o m public void setUp() throws Exception { client = mock(SolrClient.class); accessConfig = mock(AccessConfig.class); when(accessConfig.getIndexSupplier()).thenReturn(sensorType -> sensorType); solrSearchDao = new SolrSearchDao(client, accessConfig); solrRetrieveLatestDao = new SolrRetrieveLatestDao(client, accessConfig); mockStatic(CollectionAdminRequest.class); when(CollectionAdminRequest.listCollections(client)).thenReturn(Arrays.asList("bro", "snort")); }
From source file:org.codice.ddf.commands.solr.SolrCommandTest.java
License:Open Source License
protected static void createDefaultCollection() throws Exception { CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(DEFAULT_CORE_NAME, DEFAULT_CONFIGSET, 1, 1);/* w w w. j av a 2 s . c o m*/ CollectionAdminResponse response = create.process(miniSolrCloud.getSolrClient()); if (response.getStatus() != 0 || response.getErrorMessages() != null) { fail("Could not create collection. Response: " + response.toString()); } List<String> collections = CollectionAdminRequest.listCollections(miniSolrCloud.getSolrClient()); assertThat(collections.size(), is(1)); miniSolrCloud.getSolrClient().setDefaultCollection(DEFAULT_CORE_NAME); }
From source file:org.codice.ddf.commands.solr.SolrCommandTest.java
License:Open Source License
protected static void cleanupCollections() throws Exception { List<String> collections = CollectionAdminRequest.listCollections(miniSolrCloud.getSolrClient()); for (String collection : collections) { CollectionAdminRequest.Delete delete = CollectionAdminRequest.deleteCollection(collection); delete.process(miniSolrCloud.getSolrClient()); }//from w w w. ja v a 2 s . c o m }
From source file:org.opencb.commons.datastore.solr.SolrManager.java
License:Apache License
/** * Check if a given collection exists./*ww w .jav a 2 s. co m*/ * * @param collectionName Collection name * @return True or false * @throws SolrException SolrException */ public boolean existsCollection(String collectionName) throws SolrException { try { List<String> collections = CollectionAdminRequest.listCollections(solrClient); for (String collection : collections) { if (collection.equals(collectionName)) { return true; } } return false; } catch (Exception e) { throw new SolrException(SolrException.ErrorCode.CONFLICT, e); } }