Search in sources :

Example 16 with RefreshResponse

use of org.elasticsearch.action.admin.indices.refresh.RefreshResponse in project elasticsearch by elastic.

the class ESIntegTestCase method refresh.

/**
     * Waits for relocations and refreshes all indices in the cluster.
     *
     * @see #waitForRelocation()
     */
protected final RefreshResponse refresh(String... indices) {
    waitForRelocation();
    // TODO RANDOMIZE with flush?
    RefreshResponse actionGet = client().admin().indices().prepareRefresh(indices).execute().actionGet();
    assertNoFailures(actionGet);
    return actionGet;
}
Also used : RefreshResponse(org.elasticsearch.action.admin.indices.refresh.RefreshResponse)

Example 17 with RefreshResponse

use of org.elasticsearch.action.admin.indices.refresh.RefreshResponse in project crate by crate.

the class ESIntegTestCase method refresh.

/**
 * Waits for relocations and refreshes all indices in the cluster.
 *
 * @see #waitForRelocation()
 */
protected final RefreshResponse refresh(String... indices) {
    waitForRelocation();
    // TODO RANDOMIZE with flush?
    RefreshResponse actionGet = client().admin().indices().prepareRefresh(indices).execute().actionGet();
    assertNoFailures(actionGet);
    return actionGet;
}
Also used : RefreshResponse(org.elasticsearch.action.admin.indices.refresh.RefreshResponse)

Example 18 with RefreshResponse

use of org.elasticsearch.action.admin.indices.refresh.RefreshResponse in project molgenis by molgenis.

the class ClientFacade method refreshIndexes.

private void refreshIndexes(List<Index> indexes) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("Refreshing index(es) '{}' ...", toString(indexes));
    }
    String[] indexNames = toIndexNames(indexes);
    RefreshRequest refreshRequest = new RefreshRequest(indexNames);
    RefreshResponse refreshResponse;
    try {
        refreshResponse = client.indices().refresh(refreshRequest, DEFAULT);
    } catch (ElasticsearchException e) {
        if (e.status().getStatus() == 404) {
            throw new UnknownIndexException(indexes.stream().map(Index::getName).toList(), e);
        }
        throw new IndexRefreshException(indexes.stream().map(Index::getName).toList());
    } catch (IOException e) {
        throw new IndexRefreshException(indexes.stream().map(Index::getName).toList(), e);
    }
    if (refreshResponse.getFailedShards() > 0) {
        if (LOG.isErrorEnabled()) {
            LOG.error(stream(refreshResponse.getShardFailures()).map(ShardOperationFailedException::toString).collect(joining("\n")));
        }
        throw new IndexRefreshException(indexes.stream().map(Index::getName).toList());
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Refreshed index(es) '{}'", toString(indexes));
    }
}
Also used : RefreshRequest(org.elasticsearch.action.admin.indices.refresh.RefreshRequest) RefreshResponse(org.elasticsearch.action.admin.indices.refresh.RefreshResponse) IndexRefreshException(org.molgenis.data.index.exception.IndexRefreshException) UnknownIndexException(org.molgenis.data.index.exception.UnknownIndexException) Index(org.molgenis.data.elasticsearch.generator.model.Index) ElasticsearchException(org.elasticsearch.ElasticsearchException) IOException(java.io.IOException) ShardOperationFailedException(org.elasticsearch.action.ShardOperationFailedException)

Aggregations

RefreshResponse (org.elasticsearch.action.admin.indices.refresh.RefreshResponse)18 SearchResponse (org.elasticsearch.action.search.SearchResponse)6 ElasticsearchException (org.elasticsearch.ElasticsearchException)5 RefreshRequest (org.elasticsearch.action.admin.indices.refresh.RefreshRequest)5 IOException (java.io.IOException)3 GetResponse (org.elasticsearch.action.get.GetResponse)3 IndexResponse (org.elasticsearch.action.index.IndexResponse)3 SearchPhaseExecutionException (org.elasticsearch.action.search.SearchPhaseExecutionException)3 Settings (org.elasticsearch.common.settings.Settings)3 ShardOperationFailedException (org.elasticsearch.action.ShardOperationFailedException)2 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)2 FlushResponse (org.elasticsearch.action.admin.indices.flush.FlushResponse)2 ArrayList (java.util.ArrayList)1 NodeStats (org.elasticsearch.action.admin.cluster.node.stats.NodeStats)1 NodesStatsResponse (org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse)1 ClearIndicesCacheResponse (org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse)1 CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)1 ForceMergeResponse (org.elasticsearch.action.admin.indices.forcemerge.ForceMergeResponse)1 BulkResponse (org.elasticsearch.action.bulk.BulkResponse)1 DeleteResponse (org.elasticsearch.action.delete.DeleteResponse)1