org.elasticsearch.action.admin.indices.close.CloseIndexRequest Java Examples

The following examples show how to use org.elasticsearch.action.admin.indices.close.CloseIndexRequest. 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: CrudDemo.java    From javabase with Apache License 2.0 6 votes vote down vote up
/**
 * 索引的相关操作
 *
 * @param indicesAdminClient
 * @param indexName
 * @throws IOException
 */
private static void indexConfig(IndicesAdminClient indicesAdminClient, String indexName) throws IOException {
    //settings 设置
    String settings = getIndexSetting();
    // PUT /my_temp_index/_settings updatesettings
    showIndexSettings(indicesAdminClient,indexName);
    UpdateSettingsResponse updateSettingsResponse = indicesAdminClient.prepareUpdateSettings(indexName).setSettings(settings).execute().actionGet();
    log.info("更新 index setting:{}", updateSettingsResponse);


    //更新索引settings之前要关闭索引
    indicesAdminClient.close(new CloseIndexRequest().indices(indexName)).actionGet();
    //配置拼音自定义分析器
    indicesAdminClient.prepareUpdateSettings(indexName).setSettings(getIndexPinYinSetting()).execute().actionGet();
    //自定义分析器
    indicesAdminClient.prepareUpdateSettings(indexName).setSettings(getIndexDemoSetting()).execute().actionGet();
    //打开索引
    indicesAdminClient.open(new OpenIndexRequest().indices(indexName)).actionGet();

    //索引别名映射
    createAliasIndex(indicesAdminClient);

    showIndexSettings(indicesAdminClient,indexName);
}
 
Example #2
Source File: RestCloseIndexAction.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
@Override
public void handleRequest(final RestRequest request, final RestChannel channel, final Client client) {
    CloseIndexRequest closeIndexRequest = new CloseIndexRequest(Strings.splitStringByCommaToArray(request.param("index")));
    closeIndexRequest.masterNodeTimeout(request.paramAsTime("master_timeout", closeIndexRequest.masterNodeTimeout()));
    closeIndexRequest.timeout(request.paramAsTime("timeout", closeIndexRequest.timeout()));
    closeIndexRequest.indicesOptions(IndicesOptions.fromRequest(request, closeIndexRequest.indicesOptions()));
    client.admin().indices().close(closeIndexRequest, new AcknowledgedRestListener<CloseIndexResponse>(channel));
}
 
Example #3
Source File: CloseIndexRequestBuilder.java    From elasticshell with Apache License 2.0 5 votes vote down vote up
@Override
protected XContentBuilder toXContent(CloseIndexRequest request, CloseIndexResponse response, XContentBuilder builder) throws IOException {
    return builder.startObject()
            .field(Fields.OK, true)
            .field(Fields.ACKNOWLEDGED, response.isAcknowledged())
            .endObject();
}
 
Example #4
Source File: Test.java    From dht-spider with MIT License 4 votes vote down vote up
public static void closeIndex() throws Exception{
    CloseIndexRequest request = new CloseIndexRequest("haha");

    AcknowledgedResponse closeIndexResponse = client.indices().close(request, RequestOptions.DEFAULT);
    System.out.println(closeIndexResponse.isAcknowledged());
}
 
Example #5
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public ActionFuture<CloseIndexResponse> close(final CloseIndexRequest request) {
    return execute(CloseIndexAction.INSTANCE, request);
}
 
Example #6
Source File: AbstractClient.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
@Override
public void close(final CloseIndexRequest request, final ActionListener<CloseIndexResponse> listener) {
    execute(CloseIndexAction.INSTANCE, request, listener);
}
 
Example #7
Source File: CloseIndexRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
public CloseIndexRequestBuilder(Client client, JsonToString<JsonInput> jsonToString, StringToJson<JsonOutput> stringToJson) {
    super(client, new CloseIndexRequest(null), jsonToString, stringToJson);
}
 
Example #8
Source File: CloseIndexRequestBuilder.java    From elasticshell with Apache License 2.0 4 votes vote down vote up
@Override
protected ActionFuture<CloseIndexResponse> doExecute(CloseIndexRequest request) {
    return client.admin().indices().close(request);
}
 
Example #9
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Closes an index based on the index name.
 *
 * @param request The close index request
 * @return The result future
 * @see org.elasticsearch.client.Requests#closeIndexRequest(String)
 */
ActionFuture<CloseIndexResponse> close(CloseIndexRequest request);
 
Example #10
Source File: IndicesAdminClient.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Closes an index based on the index name.
 *
 * @param request  The close index request
 * @param listener A listener to be notified with a result
 * @see org.elasticsearch.client.Requests#closeIndexRequest(String)
 */
void close(CloseIndexRequest request, ActionListener<CloseIndexResponse> listener);
 
Example #11
Source File: Requests.java    From Elasticsearch with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a close index request.
 *
 * @param index The index to close
 * @return The delete index request
 * @see org.elasticsearch.client.IndicesAdminClient#close(org.elasticsearch.action.admin.indices.close.CloseIndexRequest)
 */
public static CloseIndexRequest closeIndexRequest(String index) {
    return new CloseIndexRequest(index);
}