|
|
@@ -1,11 +1,13 @@
|
|
|
package com.dgtis.data.api;
|
|
|
|
|
|
+import com.arronlong.httpclientutil.HttpClientUtil;
|
|
|
+import com.arronlong.httpclientutil.common.HttpConfig;
|
|
|
+import com.arronlong.httpclientutil.exception.HttpProcessException;
|
|
|
+import com.dgtis.common.core.utils.DateUtils;
|
|
|
import com.dgtis.common.core.web.controller.BaseController;
|
|
|
import com.dgtis.common.core.web.domain.AjaxResult;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
-import org.elasticsearch.action.get.GetResponse;
|
|
|
-import org.elasticsearch.client.transport.TransportClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
@@ -26,22 +28,40 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
@RequestMapping("/api")
|
|
|
public class DocumentApiController extends BaseController {
|
|
|
|
|
|
- @Autowired
|
|
|
- private TransportClient transportClient;
|
|
|
+ /* @Autowired
|
|
|
+ private TransportClient transportClient;*/
|
|
|
|
|
|
@Autowired
|
|
|
private ObjectMapper objectMapper;
|
|
|
|
|
|
- @GetMapping("/getIndex")
|
|
|
+ /*@GetMapping("/getIndex")
|
|
|
@ResponseBody
|
|
|
public AjaxResult getIndex() {
|
|
|
|
|
|
GetResponse response = transportClient.prepareGet("shanglifeecif.individual","default_type_", "1").get();
|
|
|
String result = response.getSourceAsString();
|
|
|
return AjaxResult.success(result);
|
|
|
- }
|
|
|
+ }*/
|
|
|
|
|
|
+ @GetMapping("/getIndex")
|
|
|
+ @ResponseBody
|
|
|
+ public AjaxResult getById() {
|
|
|
+ // 获取索引的别名,字段,创建时间
|
|
|
+ System.out.println(DateUtils.getTime());
|
|
|
+ HttpConfig config = HttpConfig.custom().url("http://10.32.2.231:9200/shanglifeecif.individual/_search?from=1&size=10");
|
|
|
+ System.out.println(DateUtils.getTime());
|
|
|
+ String jsonStr = null;
|
|
|
+ try {
|
|
|
+
|
|
|
+ jsonStr = HttpClientUtil.get(config);
|
|
|
+ System.out.println(DateUtils.getTime());
|
|
|
+ } catch (HttpProcessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ return null;
|
|
|
+ }
|
|
|
|
|
|
+ return AjaxResult.success(jsonStr);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|