org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest Java Examples

The following examples show how to use org.elasticsearch.action.admin.indices.settings.put.UpdateSettingsRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ElasticsearchPersistWriter.java    From streams with Apache License 2.0 6 votes vote down vote up
private void resetRefreshInterval() {
  for (String indexName : this.affectedIndexes) {

    if (this.veryLargeBulk) {
      LOGGER.debug("Resetting our Refresh Interval: {}", indexName);
      // They are in 'very large bulk' mode and the process is finished. We now want to turn the
      // refreshing back on.
      UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(indexName);
      updateSettingsRequest.settings(Settings.settingsBuilder().put("refresh_interval", "5s"));

      // submit to ElasticSearch
      this.manager.client()
          .admin()
          .indices()
          .updateSettings(updateSettingsRequest)
          .actionGet();
    }
  }
}
 
Example #2
Source File: ElasticsearchPersistWriter.java    From streams with Apache License 2.0 6 votes vote down vote up
protected void disableRefresh() {

    for (String indexName : this.affectedIndexes) {
      // They are in 'very large bulk' mode we want to turn off refreshing the index.
      // Create a request then add the setting to tell it to stop refreshing the interval
      UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(indexName);
      updateSettingsRequest.settings(Settings.settingsBuilder().put("refresh_interval", -1));

      // submit to ElasticSearch
      this.manager.client()
          .admin()
          .indices()
          .updateSettings(updateSettingsRequest)
          .actionGet();
    }
  }
 
Example #3
Source File: BaseClient.java    From elasticsearch-helper with Apache License 2.0 6 votes vote down vote up
public void updateIndexSetting(String index, String key, Object value) throws IOException {
    if (client() == null) {
        return;
    }
    if (index == null) {
        throw new IOException("no index name given");
    }
    if (key == null) {
        throw new IOException("no key given");
    }
    if (value == null) {
        throw new IOException("no value given");
    }
    Settings.Builder settingsBuilder = Settings.settingsBuilder();
    settingsBuilder.put(key, value.toString());
    UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest(index)
            .settings(settingsBuilder);
    client().execute(UpdateSettingsAction.INSTANCE, updateSettingsRequest).actionGet();
}
 
Example #4
Source File: ElasticsearchClient.java    From yacy_grid_mcp with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void settings(String indexName) {
    UpdateSettingsRequest request = new UpdateSettingsRequest(indexName);
    String settingKey = "index.mapping.total_fields.limit";
    int settingValue = 10000;
    Settings.Builder settingsBuilder =
            Settings.builder()
            .put(settingKey, settingValue);
    request.settings(settingsBuilder); 
    CreateIndexRequest updateSettingsResponse =
            this.elasticsearchClient.admin().indices().prepareCreate(indexName).setSettings(settingsBuilder).request();
}
 
Example #5
Source File: BlobIndices.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * can be used to alter the number of replicas.
 *
 * @param tableName name of the blob table
 * @param indexSettings updated index settings
 */
public ListenableFuture<Void> alterBlobTable(String tableName, Settings indexSettings) {
    final SettableFuture<Void> result = SettableFuture.create();
    ActionListener<UpdateSettingsResponse> listener = ActionListeners.wrap(result, Functions.<Void>constant(null));
    transportUpdateSettingsActionProvider.get().execute(
        new UpdateSettingsRequest(indexSettings, fullIndexName(tableName)), listener);
    return result;
}
 
Example #6
Source File: AlterTableOperation.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
private ListenableFuture<Long> updateSettings(TableParameter concreteTableParameter, String... indices) {
    if (concreteTableParameter.settings().getAsMap().isEmpty() || indices.length == 0) {
        return Futures.immediateFuture(null);
    }
    UpdateSettingsRequest request = new UpdateSettingsRequest(concreteTableParameter.settings(), indices);
    request.indicesOptions(IndicesOptions.lenientExpandOpen());

    SettableFuture<Long> result = SettableFuture.create();
    transportActionProvider.transportUpdateSettingsAction().execute(request,
            new SettableFutureToNullActionListener<UpdateSettingsResponse>(result));
    return result;
}
 
Example #7
Source File: Indexer.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Adds settings to index
 * 
 * @param index
 *            - name of the index
 * @param setting
 *            - settings represented as a JSON String
 * @throws IOException
 */
private static void addIndexSetting(String index, String setting) throws IOException {
	UpdateSettingsRequest updateSettingsRequest = new UpdateSettingsRequest();
	updateSettingsRequest.indices(index);
	updateSettingsRequest.settings(setting, XContentType.JSON);
	UpdateSettingsResponse updateSettingsResponse = highLevelClient.indices().putSettings(updateSettingsRequest,
			getWriteHeaders());
	if (updateSettingsResponse.isAcknowledged() == true) {
		System.out.println("[INDEXER] \tSettings have been added to " + index);
	}
}
 
Example #8
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<UpdateSettingsResponse> updateSettings(final UpdateSettingsRequest request) {
    return execute(UpdateSettingsAction.INSTANCE, request);
}
 
Example #9
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void updateSettings(final UpdateSettingsRequest request, final ActionListener<UpdateSettingsResponse> listener) {
    execute(UpdateSettingsAction.INSTANCE, request, listener);
}
 
Example #10
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<AcknowledgedResponse> updateSettings(final UpdateSettingsRequest request) {
    return execute(UpdateSettingsAction.INSTANCE, request);
}
 
Example #11
Source File: AbstractClient.java    From crate with Apache License 2.0 4 votes vote down vote up
@Override
public void updateSettings(final UpdateSettingsRequest request, final ActionListener<AcknowledgedResponse> listener) {
    execute(UpdateSettingsAction.INSTANCE, request, listener);
}
 
Example #12
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Updates settings of one or more indices.
 *
 * @param request the update settings request
 * @return The result future
 */
ActionFuture<UpdateSettingsResponse> updateSettings(UpdateSettingsRequest request);
 
Example #13
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Updates settings of one or more indices.
 *
 * @param request  the update settings request
 * @param listener A listener to be notified with the response
 */
void updateSettings(UpdateSettingsRequest request, ActionListener<UpdateSettingsResponse> listener);
 
Example #14
Source File: Requests.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * A request to update indices settings.
 *
 * @param indices The indices to update the settings for. Use <tt>null</tt> or <tt>_all</tt> to executed against all indices.
 * @return The request
 */
public static UpdateSettingsRequest updateSettingsRequest(String... indices) {
    return new UpdateSettingsRequest(indices);
}
 
Example #15
Source File: IndicesAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Updates settings of one or more indices.
 *
 * @param request the update settings request
 * @return The result future
 */
ActionFuture<AcknowledgedResponse> updateSettings(UpdateSettingsRequest request);
 
Example #16
Source File: IndicesAdminClient.java    From crate with Apache License 2.0 2 votes vote down vote up
/**
 * Updates settings of one or more indices.
 *
 * @param request  the update settings request
 * @param listener A listener to be notified with the response
 */
void updateSettings(UpdateSettingsRequest request, ActionListener<AcknowledgedResponse> listener);