ES之RestHighLevelClient

package com.luding.diankan.es.utils;

import org.apache.http.HttpHost;
import org.apache.http.client.config.RequestConfig;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.Arrays;


/**
 * @author xtm
 * es初始化
 */
@Component
public class ElasticsearchConfig {
    @Value("${elasticSearch.url}")
    private String esUrl;
    @Value("${elasticSearch.port}")
    private String esPort;

    @Value("${elasticSearch.indexName}")
    private String esIndexName;


    @Bean
    public RestHighLevelClient restHighLevelClient() {
        String[] ips = esUrl.split(",");
        Ht

Guess you like

Origin blog.csdn.net/zsj777/article/details/121362919