一  ES客户端

  ES提供多种不同的客户端:

    1、TransportClient

    ES提供的传统客户端,官方计划8.0版本删除此客户端。

    2、RestClient

    RestClient是官方推荐使用的,它包括两种:Java Low Level REST Client和 Java High Level REST Client。

    ES在6.0之后提供 Java High Level REST Client, 两种客户端官方更推荐使用 Java High Level REST Client,不过当前它还处于完善中,有些功能还没有。

    3 spring-data-elasticsearch

    这个是基于TransportClient开发的,虽然在有些版本还是可以用,但是更新对应版本太慢了

采用 Java High Level REST Client,如果它有不支持的功能,则使用Java Low Level REST Client。

二 整合

  首先是pom.xml

  注意我这个地方引入的是springbooot2.0.1   版本,首先这么做下去,再升级

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  4. <modelVersion>4.0.</modelVersion>
  5. <parent>
  6. <groupId>org.springframework.boot</groupId>
  7. <artifactId>spring-boot-starter-parent</artifactId>
  8. <version>2.0..RELEASE</version>
  9. <relativePath/> <!-- lookup parent from repository -->
  10. </parent>
  11. <groupId>com.cxy</groupId>
  12. <artifactId>elasticsearch</artifactId>
  13. <version>0.0.-SNAPSHOT</version>
  14. <name>elasticsearch</name>
  15. <description>Demo project for Spring Boot</description>
  16.  
  17. <properties>
  18. <java.version>1.8</java.version>
  19. </properties>
  20.  
  21. <dependencies>
  22. <dependency>
  23. <groupId>org.springframework.boot</groupId>
  24. <artifactId>spring-boot-starter-web</artifactId>
  25. </dependency>
  26. <dependency>
  27. <groupId>org.elasticsearch.client</groupId>
  28. <artifactId>elasticsearch-rest-high-level-client</artifactId>
  29. <version>6.2.</version>
  30. </dependency>
  31. <dependency>
  32. <groupId>org.elasticsearch</groupId>
  33. <artifactId>elasticsearch</artifactId>
  34. <version>6.2.</version>
  35. </dependency>
  36. <dependency>
  37. <groupId>org.springframework.boot</groupId>
  38. <artifactId>spring-boot-starter-test</artifactId>
  39. <scope>test</scope>
  40. </dependency>
  41. <dependency>
  42. <groupId>com.alibaba</groupId>
  43. <artifactId>fastjson</artifactId>
  44. </dependency>
  45. <dependency>
  46. <groupId>org.apache.commons</groupId>
  47. <artifactId>commons-io</artifactId>
  48. </dependency>
  49. <dependency>
  50. <groupId>org.apache.commons</groupId>
  51. <artifactId>commons-lang3</artifactId>
  52. </dependency>
  53. <dependency>
  54. <groupId>org.springframework.boot</groupId>
  55. <artifactId>spring-boot-starter-test</artifactId>
  56. <scope>test</scope>
  57. </dependency>
  58. </dependencies>
  59.  
  60. <build>
  61. <plugins>
  62. <plugin>
  63. <groupId>org.springframework.boot</groupId>
  64. <artifactId>spring-boot-maven-plugin</artifactId>
  65. </plugin>
  66. </plugins>
  67. </build>
  68.  
  69. </project>

yml文件:

  1. server:
  2. port: ${port:}
  3. spring:
  4. application:
  5. name:search-service
  6. elasticsearch:
  7. hostlist: ${eshostlist:127.0.0.1:}

es的配置类:

  1. package com.cxy.elasticsearch.config;
  2.  
  3. import org.apache.http.HttpHost;
  4. import org.elasticsearch.client.RestClient;
  5. import org.elasticsearch.client.RestHighLevelClient;
  6. import org.springframework.beans.factory.annotation.Value;
  7. import org.springframework.context.annotation.Bean;
  8. import org.springframework.context.annotation.Configuration;
  9.  
  10. @Configuration
  11. public class ElasticsearchConfig {
  12.  
  13. @Value("${spring.elasticsearch.hostlist}")
  14. private String hostlist;
  15.  
  16. @Bean
  17. public RestHighLevelClient restHighLevelClient(){
  18. //解析hostlist配置信息
  19. String[] split = hostlist.split(",");
  20. //创建HttpHost数组,其中存放es主机和端口的配置信息
  21. HttpHost[] httpHostArray = new HttpHost[split.length];
  22. for(int i=;i<split.length;i++){
  23. String item = split[i];
  24. httpHostArray[i] = new HttpHost(item.split(":")[], Integer.parseInt(item.split(":")[]), "http");
  25. }
  26. //创建RestHighLevelClient客户端
  27. return new RestHighLevelClient(RestClient.builder(httpHostArray));
  28. }
  29.  
  30. //项目主要使用RestHighLevelClient,对于低级的客户端暂时不用
  31. @Bean
  32. public RestClient restClient(){
  33. //解析hostlist配置信息
  34. String[] split = hostlist.split(",");
  35. //创建HttpHost数组,其中存放es主机和端口的配置信息
  36. HttpHost[] httpHostArray = new HttpHost[split.length];
  37. for(int i=;i<split.length;i++){
  38. String item = split[i];
  39. httpHostArray[i] = new HttpHost(item.split(":")[], Integer.parseInt(item.split(":")[]), "http");
  40. }
  41. return RestClient.builder(httpHostArray).build();
  42. }
  43.  
  44. }

然后再看我的controller

  1. package com.cxy.elasticsearch.controller;
  2.  
  3. import org.elasticsearch.action.DocWriteResponse;
  4. import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
  5. import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
  6. import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
  7. import org.elasticsearch.action.get.GetRequest;
  8. import org.elasticsearch.action.get.GetResponse;
  9. import org.elasticsearch.action.index.IndexRequest;
  10. import org.elasticsearch.action.index.IndexResponse;
  11. import org.elasticsearch.action.support.master.AcknowledgedResponse;
  12. import org.elasticsearch.client.IndicesClient;
  13. import org.elasticsearch.client.RestClient;
  14. import org.elasticsearch.client.RestHighLevelClient;
  15. import org.elasticsearch.common.settings.Settings;
  16. import org.elasticsearch.common.xcontent.XContentType;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.stereotype.Controller;
  19. import org.springframework.web.bind.annotation.RequestMapping;
  20. import org.springframework.web.bind.annotation.RequestMethod;
  21. import org.springframework.web.bind.annotation.RestController;
  22.  
  23. import java.io.IOException;
  24. import java.text.SimpleDateFormat;
  25. import java.util.Date;
  26. import java.util.HashMap;
  27. import java.util.Map;
  28.  
  29. @RestController
  30. public class EsController {
  31. @Autowired
  32. RestHighLevelClient client;
  33.  
  34. @Autowired
  35. RestClient restClient;
  36. @RequestMapping(value = "/createIndex" ,method = RequestMethod.POST)
  37. public String createIndex(){
  38. //创建索引请求对象
  39. CreateIndexRequest createIndexRequest = new CreateIndexRequest("chenxuyou3");
  40. // 设置参数
  41. createIndexRequest.settings(Settings.builder().put("number_of_shards","").put("number_of_replicas",""));
  42. //指定映射
  43. createIndexRequest.mapping("doc"," {\n" +
  44. " \t\"properties\": {\n" +
  45. " \"studymodel\":{\n" +
  46. " \"type\":\"keyword\"\n" +
  47. " },\n" +
  48. " \"name\":{\n" +
  49. " \"type\":\"keyword\"\n" +
  50. " },\n" +
  51. " \"description\": {\n" +
  52. " \"type\": \"text\",\n" +
  53. " \"analyzer\":\"ik_max_word\",\n" +
  54. " \"search_analyzer\":\"ik_smart\"\n" +
  55. " },\n" +
  56. " \"pic\":{\n" +
  57. " \"type\":\"text\",\n" +
  58. " \"index\":false\n" +
  59. " }\n" +
  60. " \t}\n" +
  61. "}", XContentType.JSON);
  62. //指定索引操作的客户端
  63. IndicesClient indices = client.indices();
  64. //执行创建索引库
  65. CreateIndexResponse createIndexResponse = null;
  66. try {
  67. createIndexResponse = indices.create(createIndexRequest);
  68. } catch (IOException e) {
  69. e.printStackTrace();
  70. }
  71. boolean acknowledged = createIndexResponse.isAcknowledged();
  72. //获取返回结果
  73. System.err.println(acknowledged);
  74. return "ok";
  75. }
  76. @RequestMapping(value = "/deleteIndex",method = RequestMethod.POST)
  77. public String deleteIndex(){
  78. DeleteIndexRequest chenxuyou3 = new DeleteIndexRequest("chenxuyou2");
  79. IndicesClient indices = client.indices();
  80. AcknowledgedResponse delete =null;
  81. try {
  82. delete = indices.delete(chenxuyou3);
  83. } catch (IOException e) {
  84. e.printStackTrace();
  85. }
  86. boolean acknowledged = delete.isAcknowledged();
  87. System.err.println(acknowledged);
  88. return "";
  89. }
  90. @RequestMapping(value = "/addDoc",method = RequestMethod.POST)
  91. public String addDoc(){
  92. //文档内容
  93. //准备json数据
  94. Map<String, Object> jsonMap = new HashMap<>();
  95. jsonMap.put("name", "spring cloud实战");
  96. jsonMap.put("description", "本课程主要从四个章节进行讲解: 1.微服务架构入门 2.spring cloud 基础入门 3.实战Spring Boot 4.注册中心eureka。");
  97. jsonMap.put("studymodel", "");
  98. SimpleDateFormat dateFormat =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  99. jsonMap.put("timestamp", dateFormat.format(new Date()));
  100. jsonMap.put("price", 5.6f);
  101.  
  102. //创建索引创建对象
  103. //带有type的方法已经废弃
  104. // IndexRequest indexRequest = new IndexRequest("chenxuyou3","doc");
  105. IndexRequest indexRequest = new IndexRequest("chenxuyou3");
  106. //文档内容
  107. indexRequest.source(jsonMap);
  108. //通过client进行http的请求
  109. IndexResponse indexResponse = null;
  110. try {
  111. indexResponse = client.index(indexRequest);
  112. } catch (IOException e) {
  113. e.printStackTrace();
  114. }
  115. DocWriteResponse.Result result = indexResponse.getResult();
  116. System.err.println(result);
  117. return "ok";
  118. }
  119. @RequestMapping(value = "/selectDoc",method = RequestMethod.GET)
  120. public String selectDoc(){
  121. //查询请求对象
  122. // GetRequest getRequest = new GetRequest("chenxuyou2","doc","8tyV-m4B7rvW_ZY4LvVU");
  123. GetRequest getRequest = new GetRequest("chenxuyou3","doc","8tyV-m4B7rvW_ZY4LvVU");
  124. GetResponse getResponse = null;
  125. try {
  126. getResponse = client.get(getRequest);
  127. } catch (IOException e) {
  128. e.printStackTrace();
  129. }
  130. //得到文档的内容
  131. Map<String, Object> sourceAsMap = getResponse.getSourceAsMap();
  132. System.out.println(sourceAsMap);
  133. return "ok" ;
  134. }
  135.  
  136. }

然后启动项目可以看到很清晰的运行

调用 localhost:8085/createIndex

可以看到成功了,后面的也就自然可以操作了。

三  问题一:

修改springboot的版本为2.1.8,环境:我使用的es版本是6.2.1 版本:

出现问题:

  1. {
  2. "timestamp": "2019-12-15T04:46:53.518+0000",
  3. "status": ,
  4. "error": "Internal Server Error",
  5. "message": "org.elasticsearch.client.Request.<init>(Ljava/lang/String;Ljava/lang/String;)V",
  6. "path": "/createIndex"
  7. }

控制台:

  1. java.lang.NoSuchMethodError: org.elasticsearch.client.Request.<init>(Ljava/lang/String;Ljava/lang/String;)V
  2. at org.elasticsearch.client.RestClient.performRequest(RestClient.java:) ~[elasticsearch-rest-client-6.4..jar:6.2.]
  3. at org.elasticsearch.client.RestHighLevelClient.performRequest(RestHighLevelClient.java:) ~[elasticsearch-rest-high-level-client-6.2..jar:6.2.]
  4. at org.elasticsearch.client.RestHighLevelClient.performRequestAndParseEntity(RestHighLevelClient.java:) ~[elasticsearch-rest-high-level-client-6.2..jar:6.2.]
  5. at org.elasticsearch.client.IndicesClient.create(IndicesClient.java:) ~[elasticsearch-rest-high-level-client-6.2..jar:6.2.]
  6. at com.cxy.elasticsearch.controller.EsController.createIndex(EsController.java:) ~[classes/:na]
  7. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_191]
  8. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:) ~[na:1.8.0_191]
  9. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:) ~[na:1.8.0_191]
  10. at java.lang.reflect.Method.invoke(Method.java:) ~[na:1.8.0_191]
  11. at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  12. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  13. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  14. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  15. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  16. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  17. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  18. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  19. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  20. at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  21. at javax.servlet.http.HttpServlet.service(HttpServlet.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  22. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:) ~[spring-webmvc-5.1..RELEASE.jar:5.1..RELEASE]
  23. at javax.servlet.http.HttpServlet.service(HttpServlet.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  24. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  25. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  26. at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:) ~[tomcat-embed-websocket-9.0..jar:9.0.]
  27. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  28. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  29. at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  30. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  31. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  32. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  33. at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  34. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  35. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  36. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  37. at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  38. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  39. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  40. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  41. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  42. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:) ~[spring-web-5.1..RELEASE.jar:5.1..RELEASE]
  43. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  44. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  45. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:) ~[tomcat-embed-core-9.0..jar:9.0.]
  46. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:) [tomcat-embed-core-9.0..jar:9.0.]
  47. at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:) [tomcat-embed-core-9.0..jar:9.0.]
  48. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:) [tomcat-embed-core-9.0..jar:9.0.]
  49. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:) [tomcat-embed-core-9.0..jar:9.0.]
  50. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:) [tomcat-embed-core-9.0..jar:9.0.]
  51. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:) [tomcat-embed-core-9.0..jar:9.0.]
  52. at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:) [tomcat-embed-core-9.0..jar:9.0.]
  53. at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:) [tomcat-embed-core-9.0..jar:9.0.]
  54. at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:) [tomcat-embed-core-9.0..jar:9.0.]
  55. at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:) [tomcat-embed-core-9.0..jar:9.0.]
  56. at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:) [tomcat-embed-core-9.0..jar:9.0.]
  57. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:) [na:1.8.0_191]
  58. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:) [na:1.8.0_191]
  59. at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:) [tomcat-embed-core-9.0..jar:9.0.]
  60. at java.lang.Thread.run(Thread.java:) [na:1.8.0_191]

java.lang.NoSuchMethodError: org.elasticsearch.client.Request.<init>(Ljava/lang/String;Ljava/lang/String;)V

这句话的具体意思是这样的,就是没有这个方法,Request对象init的时候创建使用(String,String)后面v是值得意思

可以很清楚,就是升级时候,这个方法没了

  1. /** @deprecated */
  2. @Deprecated
  3. public Response performRequest(String method, String endpoint, Map<String, String> params, Header... headers) throws IOException {
  4. Request request = new Request(method, endpoint);
  5. addParameters(request, params);
  6. addHeaders(request, headers);
  7. return this.performRequest(request);
  8. }

由于这个方法已经废弃了,所以在重新去找的时候,版本升级,springboot就没有去找这个类,

所以就报错了

四 问题二

出现了上叙问题之后,我想到了解决方法,就是将client得版本升级为最新得,7.23

然后还有就是他那个type得移除,构造方法里面不能有type

最终由于跟我es版本不一致,

  1. Search problem, contains unrecognized parameter: [typed_keys]

报包含错误得字段,我在删除得时候明没什么都没有

然后将版本进行升级:升级到6.6.1就成功了

springboot使用elasticsearch的客户端操作eslaticsearch的更多相关文章

  1. ElasticSearch相关概念与客户端操作

    一.Elasticsearch概述 Elasticsearch是面向文档(document oriented)的,这意味着它可以存储整个对象或文档(document).然而它不仅仅是存储,还会索引(i ...

  2. springboot整合es客户端操作elasticsearch(五)

    springboot整合es客户端操作elasticsearch的总结: 客户端可以进行可以对所有文档进行查询,就是不加任何条件: SearchRequest searchRequest = new ...

  3. springboot整合es客户端操作elasticsearch(二)

    在上章节中整合elasticsearch客户端出现版本问题进行了处理,这章来进行springboot整合得操作 环境:elaticsearch6.2.1,springboot 2.1.8 客户端版本采 ...

  4. 使用Java客户端操作elasticsearch(二)

    承接上文,使用Java客户端操作elasticsearch,本文主要介绍 常见的配置 和Sniffer(集群探测) 的使用. 常见的配置 前面已介绍过,RestClientBuilder支持同时提供一 ...

  5. SpringBoot整合ElasticSearch实现多版本的兼容

    前言 在上一篇学习SpringBoot中,整合了Mybatis.Druid和PageHelper并实现了多数据源的操作.本篇主要是介绍和使用目前最火的搜索引擎ElastiSearch,并和Spring ...

  6. ElasticSearch+Kibana 索引操作( 附源码)

    一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elastics ...

  7. ElasticSearch+Kibana 索引操作

    ElasticSearch+Kibana 索引操作 一 前言 ElasticiSearch 简介 ElasticSearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引 ...

  8. 全文检索-Elasticsearch (四) elasticsearch.net 客户端

    本篇摘自elasticsearch.net search入门使用指南中文版(翻译) 原文:http://edu.dmeiyang.com/book/nestusing.html elasticsear ...

  9. springboot集成elasticsearch

    在基础阶段学习ES一般是首先是 安装ES后借助 Kibana 来进行CURD 了解ES的使用: 在进阶阶段可以需要学习ES的底层原理,如何通过Version来实现乐观锁保证ES不出问题等核心原理: 第 ...

随机推荐

  1. P1198最大数——线段树点修改&&模板题

    题目 题目链接 大意:维护一个数列,有两种操作: 查询操作Q  L:查询当前数列中末尾L个数中的最大的数 插入操作A  n:将n加上t再对D取模,将所得值插入数列末尾 解决方案 由题意知,只有两种操作 ...

  2. mysql自增主键清零方法

    MySQL数据库自增主键归零的几种方法 如果曾经的数据都不需要的话,可以直接清空所有数据,并将自增字段恢复从1开始计数: truncate table table_name; 1 当用户没有trunc ...

  3. selenium+pyquery爬取淘宝商品信息

    import re from selenium import webdriver from selenium.common.exceptions import TimeoutException fro ...

  4. rsync 同步操作

    同步:增量拷贝,只传输变化过的数据 rsync   [ 选项]  源目录/目标目录 -a :归档模式  相当于 -rlptgoD -v:显示详细操作信息 -z:传输过程中启用压缩/解压 --delet ...

  5. 《30天自制操作系统》学习笔记--Mac下工具的使用

    现在来介绍官网上下的工具怎么用首先是官网地址,书上有个注释上有:hrb.osask.jp 翻译成中文大概是这个样子滴. 上面有两个文件可以下载,一个是工具,一个是工具的源代码,很好的学习资料 下面把工 ...

  6. 2019icpc沈阳网络赛 D Fish eating fruit 树形dp

    题意 分别算一个树中所有简单路径长度模3为0,1,2的距离和乘2. 分析 记录两个数组, \(dp[i][k]\)为距i模3为k的子节点到i的距离和 \(f[i][k]\)为距i模3为k的子节点的个数 ...

  7. [Vue] : Vue指令

    Vue指令之 v-cloak v-cloak是解决解决插值表达式的闪烁问题 . 给插值表达式的元素加上v-cloak <p v-cloak>{{ msg }}</p> 为v-c ...

  8. JavaWeb_(Spring框架)Spring配置文件

    一.什么是spring IOC IOC(Inversion of Control)即控制反转,在我们以往的编程中如果需要一个bean往往需要去手动去new一个出来.而spring帮我们解决了这个问题, ...

  9. UVA 796 Critical Links —— (求割边(桥))

    和求割点类似,只要把>=改成>即可.这里想解释一下的是,无向图没有重边,怎么可以使得low[v]=dfn[u]呢?只要它们之间再来一个点即可. 总感觉图论要很仔细地想啊- -一不小心就弄混 ...

  10. 【洛谷1361】 小M的作物(最小割)

    传送门 洛谷 Solution 这是一个比较实用的套路,很多题目都有用,而且这个套路难以口胡出来. 考虑把每一个附加贡献重新建一个点,然后向必需的点连边,流量为val. 然后直接种植的从源点向这个点连 ...