feat(新增): 查询索引库
This commit is contained in:
parent
2d01f995c8
commit
ae0449c991
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" autoUpload="Always" remoteFilesAllowedToDisappearOnAutoupload="false" autoUploadExternalChanges="true">
|
||||
<option name="myAutoUpload" value="ALWAYS" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PrettierConfiguration">
|
||||
<option name="myRunOnSave" value="true" />
|
||||
</component>
|
||||
</project>
|
|
@ -7,12 +7,11 @@ import org.elasticsearch.client.RequestOptions;
|
|||
import org.elasticsearch.client.RestClient;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.search.rescore.RescorerBuilder;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -23,8 +22,8 @@ public class HotelIndexTest {
|
|||
void setup() throws Exception {
|
||||
this.client = new RestHighLevelClient(RestClient.builder((
|
||||
HttpHost.create("http://192.168.1.4:9200"))
|
||||
// 集群缓环境下可以配置多个
|
||||
// HttpHost.create("http://192.168.1.7:9200")
|
||||
// 集群缓环境下可以配置多个
|
||||
// HttpHost.create("http://192.168.1.7:9200")
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -59,5 +58,14 @@ public class HotelIndexTest {
|
|||
client.indices().delete(request, RequestOptions.DEFAULT);
|
||||
}
|
||||
|
||||
|
||||
// 查询索引库
|
||||
@Test
|
||||
void getHotelIndex() throws IOException {
|
||||
// 1. 创建Request对象
|
||||
GetIndexRequest request = new GetIndexRequest("hotel");
|
||||
// 2. 查询索引库
|
||||
boolean exists = client.indices().exists(request, RequestOptions.DEFAULT);
|
||||
// 输出是否删除
|
||||
System.out.println(exists);
|
||||
}
|
||||
}
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue