package io.github.qifan777.knowledge.config;

import co.elastic.clients.elasticsearch.ElasticsearchClient;
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
import co.elastic.clients.transport.rest_client.RestClientTransport;
import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <p>
 *
 * </p>
 *
 * @author taohongrun
 * @since 2025/3/17
 */
@Configuration
public class ElasticSearchConf {
    @Bean
    public ElasticsearchClient elasticSearchClient() {
        RestClient restClient=RestClient.builder(new HttpHost("58.87.69.234", 9200))
                .build();

        RestClientTransport restClientTransport = new RestClientTransport(restClient, new JacksonJsonpMapper());

        return new ElasticsearchClient(restClientTransport);
    }
}
