Search in sources :

Example 16 with UpdateResponse

use of org.apache.solr.client.solrj.response.UpdateResponse in project ddf by codice.

the class BackupCommand method optimizeCollection.

private void optimizeCollection(SolrClient client, String collection) throws IOException, SolrServerException {
    LOGGER.debug("Optimization of collection [{}] is in progress.", collection);
    printInfoMessage(String.format("Optimizing of collection [%s] is in progress.", collection));
    UpdateResponse updateResponse = client.optimize(collection);
    LOGGER.debug("Optimization status: {}", updateResponse.getStatus());
    if (updateResponse.getStatus() != 0) {
        throw new RuntimeException(String.format("Unable to optimize collection [%s].", coreName));
    }
}
Also used : UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse)

Example 17 with UpdateResponse

use of org.apache.solr.client.solrj.response.UpdateResponse in project ddf by codice.

the class SolrClientAdaptorTest method deleteByQuery.

@Test
public void deleteByQuery() throws Exception {
    whenSolrClientIsSuccessfullyRetrieved();
    UpdateResponse expectedResponse = new UpdateResponse();
    when(mockInitializedSolrClientAdaptor.deleteByQuery(TEST_DELETE_BY_QUERY_STRING)).thenReturn(expectedResponse);
    UpdateResponse response = solrClientAdaptor.deleteByQuery(TEST_DELETE_BY_QUERY_STRING);
    assertThat(response, is(expectedResponse));
    verify(mockInitializedSolrClientAdaptor).deleteByQuery(TEST_DELETE_BY_QUERY_STRING);
}
Also used : UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse) Test(org.junit.Test)

Example 18 with UpdateResponse

use of org.apache.solr.client.solrj.response.UpdateResponse in project ddf by codice.

the class UninitializedSolrClientAdaptorTest method deleteByQuery.

@Test
public void deleteByQuery() throws Exception {
    UpdateResponse response = uninitializedSolrClientAdaptor.deleteByQuery("test-delete-by-query-string");
    assertThat(response.getElapsedTime(), is(equalTo(0L)));
    assertThat(response.getRequestUrl(), is(equalTo("")));
    assertThat(response.getResponse().size(), is(equalTo(0)));
}
Also used : UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse) Test(org.junit.Test)

Example 19 with UpdateResponse

use of org.apache.solr.client.solrj.response.UpdateResponse in project ddf by codice.

the class UninitializedSolrClientAdaptor method deleteByQuery.

@Override
public UpdateResponse deleteByQuery(String query) throws SolrServerException, IOException {
    LOGGER.debug("Called deleteByQuery on un-initialized SolrClientAdaptor. Ignoring.");
    UpdateResponse updateResponse = new UpdateResponse();
    updateResponse.setElapsedTime(0);
    updateResponse.setRequestUrl("");
    updateResponse.setResponse(new NamedList<>());
    return updateResponse;
}
Also used : UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse)

Example 20 with UpdateResponse

use of org.apache.solr.client.solrj.response.UpdateResponse in project ddf by codice.

the class InitializedSolrClientAdaptorTest method deleteByQuery.

@Test
public void deleteByQuery() throws Exception {
    UpdateResponse expectedResponse = new UpdateResponse();
    when(mockSolrClient.deleteByQuery("")).thenReturn(expectedResponse);
    UpdateResponse response = initializedSolrClientAdaptor.deleteByQuery("");
    assertThat(response, is(expectedResponse));
    verify(mockSolrClient).deleteByQuery("");
}
Also used : UpdateResponse(org.apache.solr.client.solrj.response.UpdateResponse) Test(org.junit.Test)

Aggregations

UpdateResponse (org.apache.solr.client.solrj.response.UpdateResponse)43 SolrInputDocument (org.apache.solr.common.SolrInputDocument)17 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)16 IOException (java.io.IOException)13 SolrServerException (org.apache.solr.client.solrj.SolrServerException)12 ArrayList (java.util.ArrayList)10 SolrClient (org.apache.solr.client.solrj.SolrClient)8 HttpSolrClient (org.apache.solr.client.solrj.impl.HttpSolrClient)8 SolrDocument (org.apache.solr.common.SolrDocument)8 NamedList (org.apache.solr.common.util.NamedList)7 Future (java.util.concurrent.Future)6 Test (org.junit.Test)6 ExecutorService (java.util.concurrent.ExecutorService)5 SolrException (org.apache.solr.common.SolrException)5 DefaultSolrThreadFactory (org.apache.solr.util.DefaultSolrThreadFactory)5 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)4 CloudSolrClient (org.apache.solr.client.solrj.impl.CloudSolrClient)3 QueryResponse (org.apache.solr.client.solrj.response.QueryResponse)3 MalformedURLException (java.net.MalformedURLException)2 HashMap (java.util.HashMap)2