package es_02_index; import org.elasticsearch.action.support.master.AcknowledgedResponse; import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.indices.CloseIndexRequest; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.io.IOException; /** * 关闭索引 * * @author : qinyingjie * @version : 2.2.0 * @date : 2023/5/13 11:14 */ @SpringBootTest @RunWith(SpringRunner.class) public class TestIndex_08_close { @Autowired private RestHighLevelClient client; //关闭索引 @Test public void testCloseIndex() throws IOException { CloseIndexRequest request = new CloseIndexRequest("itheima_book"); AcknowledgedResponse close = client.indices().close(request, RequestOptions.DEFAULT); boolean acknowledged = close.isAcknowledged(); System.out.println("acknowledged:" + acknowledged); } }