Search in sources :

Example 11 with CreateIndexResponse

use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project fess by codelibs.

the class FessEsClient method createIndex.

public boolean createIndex(final String index, final String docType, final String indexName) {
    final FessConfig fessConfig = ComponentUtil.getFessConfig();
    waitForConfigSyncStatus();
    sendConfigFiles(index);
    final String indexConfigFile = indexConfigPath + "/" + index + ".json";
    try {
        String source = FileUtil.readUTF8(indexConfigFile);
        final String dictionaryPath = System.getProperty("fess.dictionary.path", StringUtil.EMPTY);
        source = source.replaceAll(Pattern.quote("${fess.dictionary.path}"), dictionaryPath);
        final CreateIndexResponse indexResponse = client.admin().indices().prepareCreate(indexName).setSource(source, XContentFactory.xContentType(source)).execute().actionGet(fessConfig.getIndexIndicesTimeout());
        if (indexResponse.isAcknowledged()) {
            logger.info("Created " + indexName + " index.");
            return true;
        } else if (logger.isDebugEnabled()) {
            logger.debug("Failed to create " + indexName + " index.");
        }
    } catch (final Exception e) {
        logger.warn(indexConfigFile + " is not found.", e);
    }
    return false;
}
Also used : CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) FessConfig(org.codelibs.fess.mylasta.direction.FessConfig) IllegalBehaviorStateException(org.dbflute.exception.IllegalBehaviorStateException) FessSystemException(org.codelibs.fess.exception.FessSystemException) ResultOffsetExceededException(org.codelibs.fess.exception.ResultOffsetExceededException) ResourceNotFoundRuntimeException(org.codelibs.core.exception.ResourceNotFoundRuntimeException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) ElasticsearchException(org.elasticsearch.ElasticsearchException) SearchPhaseExecutionException(org.elasticsearch.action.search.SearchPhaseExecutionException) SearchQueryException(org.codelibs.fess.exception.SearchQueryException) InvalidQueryException(org.codelibs.fess.exception.InvalidQueryException)

Example 12 with CreateIndexResponse

use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project crate by crate.

the class BlobAdminClient method createBlobTable.

public CompletableFuture<Void> createBlobTable(String tableName, Settings indexSettings) {
    Settings.Builder builder = Settings.builder();
    builder.put(indexSettings);
    builder.put(SETTING_INDEX_BLOBS_ENABLED, true);
    final CompletableFuture<Void> result = new CompletableFuture<>();
    createIndexAction.execute(new CreateIndexRequest(fullIndexName(tableName), builder.build()), new ActionListener<CreateIndexResponse>() {

        @Override
        public void onResponse(CreateIndexResponse createIndexResponse) {
            assert createIndexResponse.isAcknowledged() : "createIndexResponse must be acknowledged";
            result.complete(null);
        }

        @Override
        public void onFailure(Throwable e) {
            result.completeExceptionally(e);
        }
    });
    return result;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) CreateIndexRequest(org.elasticsearch.action.admin.indices.create.CreateIndexRequest) CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) Settings(org.elasticsearch.common.settings.Settings)

Example 13 with CreateIndexResponse

use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project elasticsearch by elastic.

the class ActiveShardsObserverIT method testCreateIndexNoActiveShardsNoWaiting.

public void testCreateIndexNoActiveShardsNoWaiting() throws Exception {
    Settings.Builder settingsBuilder = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), 0);
    if (internalCluster().getNodeNames().length > 0) {
        String exclude = String.join(",", internalCluster().getNodeNames());
        settingsBuilder.put("index.routing.allocation.exclude._name", exclude);
    }
    Settings settings = settingsBuilder.build();
    CreateIndexResponse response = prepareCreate("test-idx").setSettings(settings).setWaitForActiveShards(ActiveShardCount.NONE).get();
    assertTrue(response.isAcknowledged());
}
Also used : CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) Settings(org.elasticsearch.common.settings.Settings)

Example 14 with CreateIndexResponse

use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project elasticsearch by elastic.

the class ActiveShardsObserverIT method testCreateIndexStopsWaitingWhenIndexDeleted.

public void testCreateIndexStopsWaitingWhenIndexDeleted() throws Exception {
    final String indexName = "test-idx";
    Settings settings = Settings.builder().put(indexSettings()).put(INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), randomIntBetween(1, 5)).put(INDEX_NUMBER_OF_REPLICAS_SETTING.getKey(), internalCluster().numDataNodes() - 1).build();
    logger.info("--> start the index creation process");
    ListenableActionFuture<CreateIndexResponse> responseListener = prepareCreate(indexName).setSettings(settings).setWaitForActiveShards(ActiveShardCount.ALL).execute();
    logger.info("--> wait until the cluster state contains the new index");
    assertBusy(() -> assertTrue(client().admin().cluster().prepareState().get().getState().metaData().hasIndex(indexName)));
    logger.info("--> delete the index");
    assertAcked(client().admin().indices().prepareDelete(indexName));
    logger.info("--> ensure the create index request completes");
    assertAcked(responseListener.get());
}
Also used : CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse) Settings(org.elasticsearch.common.settings.Settings)

Example 15 with CreateIndexResponse

use of org.elasticsearch.action.admin.indices.create.CreateIndexResponse in project elasticsearch by elastic.

the class AckIT method testCreateIndexNoAcknowledgement.

public void testCreateIndexNoAcknowledgement() {
    CreateIndexResponse createIndexResponse = client().admin().indices().prepareCreate("test").setTimeout("0s").get();
    assertThat(createIndexResponse.isAcknowledged(), equalTo(false));
    //let's wait for green, otherwise there can be issues with after test checks (mock directory wrapper etc.)
    ensureGreen();
}
Also used : CreateIndexResponse(org.elasticsearch.action.admin.indices.create.CreateIndexResponse)

Aggregations

CreateIndexResponse (org.elasticsearch.action.admin.indices.create.CreateIndexResponse)19 Settings (org.elasticsearch.common.settings.Settings)7 CreateIndexRequest (org.elasticsearch.action.admin.indices.create.CreateIndexRequest)4 IOException (java.io.IOException)3 ElasticsearchException (org.elasticsearch.ElasticsearchException)3 ClusterHealthResponse (org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse)3 ClusterState (org.elasticsearch.cluster.ClusterState)3 IndexNotFoundException (org.elasticsearch.index.IndexNotFoundException)3 ResourceAlreadyExistsException (org.elasticsearch.ResourceAlreadyExistsException)2 PutMappingResponse (org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse)2 SearchPhaseExecutionException (org.elasticsearch.action.search.SearchPhaseExecutionException)2 ClusterBlockException (org.elasticsearch.cluster.block.ClusterBlockException)2 Before (org.junit.Before)2 TitanException (com.thinkaurelius.titan.core.TitanException)1 UnknownHostException (java.net.UnknownHostException)1 Map (java.util.Map)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ResourceNotFoundRuntimeException (org.codelibs.core.exception.ResourceNotFoundRuntimeException)1 FessSystemException (org.codelibs.fess.exception.FessSystemException)1