Merge branch 'main' of http://117.73.12.23:43000/liweijie/qiwen-file
This commit is contained in:
commit
2a1c41ae98
@ -4,8 +4,17 @@ import co.elastic.clients.elasticsearch.ElasticsearchClient;
|
|||||||
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
import co.elastic.clients.json.jackson.JacksonJsonpMapper;
|
||||||
import co.elastic.clients.transport.ElasticsearchTransport;
|
import co.elastic.clients.transport.ElasticsearchTransport;
|
||||||
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
import co.elastic.clients.transport.rest_client.RestClientTransport;
|
||||||
|
import java.util.Base64;
|
||||||
|
import org.apache.http.Header;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
|
import org.apache.http.auth.AuthScope;
|
||||||
|
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||||
|
import org.apache.http.client.CredentialsProvider;
|
||||||
|
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||||
|
import org.apache.http.message.BasicHeader;
|
||||||
|
import org.elasticsearch.client.RequestOptions;
|
||||||
import org.elasticsearch.client.RestClient;
|
import org.elasticsearch.client.RestClient;
|
||||||
|
import org.elasticsearch.client.RestClientBuilder;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@ -13,8 +22,9 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
public class ElasticSearchConfig {
|
public class ElasticSearchConfig {
|
||||||
@Bean
|
@Bean
|
||||||
public ElasticsearchClient elasticsearchClient(){
|
public ElasticsearchClient elasticsearchClient(){
|
||||||
RestClient client = RestClient.builder(new HttpHost("localhost", 9200,"http")).build();
|
RestClient client = RestClient.builder(new HttpHost("117.73.12.23", 49200, "http"))
|
||||||
ElasticsearchTransport transport = new RestClientTransport(client,new JacksonJsonpMapper());
|
.setDefaultHeaders(new Header[]{new BasicHeader("Authorization", "Basic " + Base64.getEncoder().encodeToString("elastic:Y123456a".getBytes()))})
|
||||||
return new ElasticsearchClient(transport);
|
.build();
|
||||||
|
return new ElasticsearchClient(new RestClientTransport(client,new JacksonJsonpMapper()));
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user