Я хочу получить данные из эластичного индекса в конечной точке API Springboot с запросом.
Elastic Version 6.X.
Мне нужен кто-нибудь, кто поможет в написании модели, репозитория, сервиса ивнедрение сервиса.Я новый эластичный и пружинный ботинок.Пожалуйста, помогите мне в этом.
Я успешно могу подключить эластик из Springboot.Теперь я хочу получить данные индекса эластичности с помощью запроса.
ElasticConfiguration.java
package com.websystique.springboot.configuration;
import java.net.InetAddress;
import java.net.UnknownHostException;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class ElasticConfiguration {
@Value("${datasource.sampleapp.elasticsearch_host:localhost}")
public String host;
@Value("${datasource.sampleapp.elasticsearch_port:9300}")
public int port;
public String getHost() {
return host;
}
public int getPort() {
return port;
}
@Bean
public Client client() {
TransportClient client = null;
try {
System.out.println("host:" + host + "port:" + port);
Settings settings = Settings.builder().put("cluster.name", "elasticsearch").put("client.transport.sniff", false).build();
client = new PreBuiltTransportClient(settings).addTransportAddress(new TransportAddress(InetAddress.getByName(getHost()), 9300));
} catch (UnknownHostException e) {
e.printStackTrace();
}
return client;
}
}
Индекс эластичности json: curl http://localhost:200/test/_search
{
"took":2,
"timed_out":false,
"_shards":{
"total":5,
"successful":5,
"skipped":0,
"failed":0
},
"hits":{
"total":621,
"max_score":1.0,
"hits":[
{
"_index":"test",
"_type":"random",
"_id":"{17da802b-ddbd-439f-86fd-92447c2b91eb}",
"_score":1.0,
"_source":{
"Data":{
"id":"{17da802b-ddbd-439f-86fd-92447c2b91eb}",
"parameters":[
{
"key":"dataflowId",
"value":"5e88476a-d241-4ef7-9654-16f2b35c6cce"
},
{
"key":"dataflowName",
"value":"Policy_Pt_DF"
},
{
"key":"destination",
"value":"repo2@00-00A5C8-4E8CE1-40F393-B18919[1-1-F]"
},
{
"key":"moverType",
"value":"eMOVER_BATCH"
},
{
"key":"operationId",
"value":"1"
},
{
"key":"policyId",
"value":"fbd5d40a4eac4c6e8b23800e5a4bd97b"
},
{
"key":"policyName",
"value":"Plocity_pl"
},
{
"key":"policyVersion",
"value":"1"
},
{
"key":"sessionId",
"value":"hdid-repo90@BC-AAGBPL-AENMIQ-VBHPK9-T8UQCH[0-1-3]#1555195303002-2676-186"
},
{
"key":"source",
"value":"hdid-client90@BW-RSQUZZ-TT44ZB-HKUTJI-EVP299[0-1-2]"
}
],
"timeStarted":"2019-04-13T22:52:18Z",
"timeUpdated":"2019-04-13T22:52:35Z",
"description":"Initial Resynchronization of FileSystem Data to Repository Store",
"actions":[
],
"timeCompleted":"2019-04-13T22:52:35Z",
"progress":"Stage 13 of 13",
"type":"eJOBTYPE_BACKUP",
"status":"eJOB_CANCELLED",
"subType":{
"id":"Resynchronize Repository Store",
"subSystem":"Repository"
},
"mainNode":{
"id":"hdid-client90@BW-RSQUZZ-TT44ZB-HKUTJI-EVP299[0-1-2]",
"instance":61
}
},
"date":"2019-04-13T22:52:18Z",
"MainNode":"hdid-client90"
}
}]
}
}