当前位置:   article > 正文

springboot整合elasticsearch实践,两种方式操作索引文档,解析附件中的内容,搜索附件中的中文_indexrequest.setpipeline

indexrequest.setpipeline

目录

一、依赖引入

二、修改配置文件

2.1、配置elasticsearch的服务地址和端口号

2.2、编写配置类连接elasticsearch

 2.3、实体类加入注解

2.4、dao继承ElasticsearchRepository

2.5、创建service接口和实现类,模拟调用。

三、开始编码测试

        3.1 、创建文档

3.2 、批量创建

3.3 、查询方法

3.4、删除方法

3.5、分页查询,条件查询

四、上传附件,可搜索附件中的中文

4.1、需要先安装附件解析插件ingest-attachment

4.2、定义管道

五、多附件上传解析

5.1、定义多附件的管道pipeline

5.2、上传附件代码实现如下


一、依赖引入

  1. <dependency>
  2. <groupId>org.springframework.boot</groupId>
  3. <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
  4. </dependency>
  5. <!-- io流文件操作 -->
  6. <dependency>
  7. <groupId>commons-io</groupId>
  8. <artifactId>commons-io</artifactId>
  9. <version>2.5</version>
  10. </dependency>
  11. <dependency>
  12. <groupId>org.elasticsearch</groupId>
  13. <artifactId>elasticsearch</artifactId>
  14. <version>7.9.0</version>
  15. </dependency>
  16. <!-- elasticsearch 的客户端 -->
  17. <dependency>
  18. <groupId>org.elasticsearch.client</groupId>
  19. <artifactId>elasticsearch-rest-high-level-client</artifactId>
  20. <version>7.9.0</version>
  21. </dependency>
  22. <!-- elasticsearch 依赖 2.x 的 log4j -->
  23. <dependency>
  24. <groupId>org.apache.logging.log4j</groupId>
  25. <artifactId>log4j-api</artifactId>
  26. <version>2.8.2</version>
  27. </dependency>
  28. <dependency>
  29. <groupId>org.apache.logging.log4j</groupId>
  30. <artifactId>log4j-core</artifactId>
  31. <version>2.8.2</version>
  32. </dependency>
  33. <dependency>
  34. <groupId>com.fasterxml.jackson.core</groupId>
  35. <artifactId>jackson-databind</artifactId>
  36. <version>2.9.9</version>
  37. </dependency>
  38. <!-- junit 单元测试 -->
  39. <dependency>
  40. <groupId>junit</groupId>
  41. <artifactId>junit</artifactId>
  42. <version>4.12</version>
  43. </dependency>
  44. <dependency>
  45. <groupId>org.springframework.boot</groupId>
  46. <artifactId>spring-boot-devtools</artifactId>
  47. <scope>runtime</scope>
  48. <optional>true</optional>
  49. </dependency>
  50. <dependency>
  51. <groupId>org.springframework.boot</groupId>
  52. <artifactId>spring-boot-configuration-processor</artifactId>
  53. <optional>true</optional>
  54. </dependency>
  55. <dependency>
  56. <groupId>org.projectlombok</groupId>
  57. <artifactId>lombok</artifactId>
  58. <optional>true</optional>
  59. </dependency>
  60. <dependency>
  61. <groupId>org.springframework.boot</groupId>
  62. <artifactId>spring-boot-starter-test</artifactId>
  63. <scope>test</scope>
  64. </dependency>
  65. <dependency>
  66. <groupId>junit</groupId>
  67. <artifactId>junit</artifactId>
  68. <version>4.13.1</version>
  69. <scope>test</scope>
  70. </dependency>
  71. <dependency>
  72. <groupId>org.springframework</groupId>
  73. <artifactId>spring-web</artifactId>
  74. <version>5.3.3</version>
  75. </dependency>
  76. <dependency>
  77. <groupId>com.ali
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/319324
推荐阅读
相关标签
  

闽ICP备14008679号