索引-查询
# GetIndexRequest
创建Test03_Index_Search
类
package com.stt.demo;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;
import java.io.IOException;
public class Test03_Index_Search {
public static void main(String[] args) throws IOException {
// 创建客户端
RestHighLevelClient client = new RestHighLevelClient(
RestClient.builder(new HttpHost("localhost", 9200, "http"))
);
// 【查询索引】 请求
GetIndexRequest request = new GetIndexRequest("user");
// 发送请求,获取响应
GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT);
System.out.println("aliases:" + response.getAliases());
System.out.println("mappings:" + response.getMappings());
System.out.println("settings:" + response.getSettings());
// 关闭客户端
client.close();
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
返回结果
aliases:{user=[]}
mappings:{user=org.elasticsearch.cluster.metadata.MappingMetadata@817d2937}
settings:{user={"index.creation_date":"1643184683888","index.number_of_replicas":"1","index.number_of_shards":"1","index.provided_name":"user","index.uuid":"jNebN2nZTqC22Qyr51sPkQ","index.version.created":"7080099"}}
1
2
3
2
3
Last Updated: 2022/02/05, 15:58:51