es文档开发

This commit is contained in:
暮光:城中城
2019-07-23 21:41:20 +08:00
parent 417132d25c
commit fc02414519
22 changed files with 205 additions and 356 deletions

View File

@@ -3,6 +3,7 @@ package com.zyplayer.doc.elasticsearch.controller;
import com.zyplayer.doc.core.json.DocResponseJson;
import com.zyplayer.doc.core.json.ResponseJson;
import com.zyplayer.doc.data.service.elasticsearch.support.ElasticSearchUtil;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetMappingsRequest;
@@ -12,6 +13,7 @@ import org.elasticsearch.common.unit.TimeValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -37,15 +39,22 @@ public class EsMappingController {
@Resource
ElasticSearchUtil elasticSearchUtil;
@GetMapping("/mappings")
public ResponseJson<Object> mappings() throws IOException {
@PostMapping("/mappings")
public ResponseJson<Object> mappings(String index) throws IOException {
GetMappingsRequest request = new GetMappingsRequest();
request.setMasterTimeout(TimeValue.timeValueMinutes(1));
RestHighLevelClient client = elasticSearchUtil.getEsClient("127.0.0.1:9200", "http");
GetMappingsResponse getMappingResponse = client.indices().getMapping(request, RequestOptions.DEFAULT);
Map<String, MappingMetaData> allMappings = getMappingResponse.mappings();
return DocResponseJson.ok(allMappings);
if (StringUtils.isNotBlank(index)) {
request.indices(index);
}
try {
RestHighLevelClient client = elasticSearchUtil.getEsClient("127.0.0.1:9200", "http");
GetMappingsResponse getMappingResponse = client.indices().getMapping(request, RequestOptions.DEFAULT);
Map<String, MappingMetaData> allMappings = getMappingResponse.mappings();
return DocResponseJson.ok(allMappings);
} catch (Exception e) {
e.printStackTrace();
}
return DocResponseJson.warn("获取文档失败");
}
@GetMapping("/list")

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,a,c){for(var u,i,f,l=0,s=[];l<t.length;l++)i=t[l],o[i]&&s.push(o[i][0]),o[i]=0;for(u in a)Object.prototype.hasOwnProperty.call(a,u)&&(e[u]=a[u]);for(r&&r(t,a,c);s.length;)s.shift()();if(c)for(l=0;l<c.length;l++)f=n(n.s=c[l]);return f};var t={},o={2:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var a=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=a;var c=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute("nonce",n.nc),u.src=n.p+""+e+".js?"+{0:"31474664fb42f0a39af3",1:"1d7b81f64deeacaf0960"}[e];var i=setTimeout(r,12e4);return u.onerror=u.onload=r,c.appendChild(u),a},n.m=e,n.c=t,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n.oe=function(e){throw console.error(e),e}}([]);
//# sourceMappingURL=doc-es-manifest.js.map?b055a21e8924d72bdfc6

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>ES文档管理</title>
</head>
<body>
<div id="app"></div>
<script type="text/javascript" src="doc-es-manifest.js?b055a21e8924d72bdfc6"></script><script type="text/javascript" src="doc-es-vendor.js?31474664fb42f0a39af3"></script><script type="text/javascript" src="doc-es-index.js?1d7b81f64deeacaf0960"></script></body>
</html>