• Es中的查询操作


    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();
        }
    }
    
  • 相关阅读:
    Zookeeper-06
    ​iOS安全加固方法及实现
    统计字符串中不同回文子序列的个数
    【MCS-51】中断系统原理及应用
    VS Code 配置C语言
    npm命令介绍
    【481. 神奇字符串】
    Vue前端打印print设置自定义参数
    Fisher信息量与Fisher观测信息量
    y139.第八章 Servless和Knative从入门到精通 -- 部署Knative(三)
  • 原文地址:https://blog.csdn.net/weixin_43882788/article/details/126574488