package com.atguigu.es.test;
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 org.elasticsearch.cluster.metadata.AliasMetadata;
import org.elasticsearch.cluster.metadata.MappingMetadata;
import org.elasticsearch.common.settings.Settings;
import java.io.IOException;
import java.util.List;
import java.util.Map;
public class ESTest_Index_Search {
public static void main(String[] args) throws IOException {
//创建ES客户端
HttpHost httpHost = new HttpHost("localhost", 9200, "http");
RestHighLevelClient esClient = new RestHighLevelClient(RestClient.builder(httpHost));
//查询索引
GetIndexRequest request = new GetIndexRequest("user");
GetIndexResponse getIndexResponse =
esClient.indices().get(request,RequestOptions.DEFAULT);
//查询的返回状态
Map> aliases = getIndexResponse.getAliases();
Map mappings = getIndexResponse.getMappings();
Map settings = getIndexResponse.getSettings();
System.out.println("aliases:"+aliases);
System.out.println("mappings:"+mappings);
System.out.println("settings:"+settings);
//关闭ES客户端
esClient.close();
}
}