增加es文档雏形~

This commit is contained in:
暮光:城中城
2019-07-21 22:41:23 +08:00
parent 25036fb197
commit fb5438e1ec
42 changed files with 13463 additions and 4 deletions

Binary file not shown.

View File

@@ -16,6 +16,9 @@ import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetMappingsRequest;
import org.elasticsearch.client.indices.GetMappingsResponse;
import org.elasticsearch.cluster.metadata.MappingMetaData;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
@@ -187,6 +190,21 @@ public class TestEsRestController {
return DocResponseJson.warn("失败");
}
@GetMapping("/mappings")
public ResponseJson<Object> mappings() throws IOException {
GetMappingsRequest request = new GetMappingsRequest();
// request.indices(ES_INDEX);
request.setMasterTimeout(TimeValue.timeValueMinutes(1));
GetMappingsResponse getMappingResponse = client.indices().getMapping(request, RequestOptions.DEFAULT);
Map<String, MappingMetaData> allMappings = getMappingResponse.mappings();
MappingMetaData indexMapping = allMappings.get(ES_INDEX);
Map<String, Object> mapping = indexMapping.sourceAsMap();
// 相关文档地址
// https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-get-settings.html
// https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-settings.html
return DocResponseJson.ok(allMappings);
}
@GetMapping("/other")
public ResponseJson<Object> other() {
return DocResponseJson.ok();