(1)、添加依赖

         <dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>6.3.1</version>
</dependency>

(2)、配置文件中配置相关属性

 spring.elasticsearch.jest.uris=http://192.168.205.128:9200

(3)、使用JestClient操作ES

     @Autowired
private JestClient jestClient; public String add() throws IOException {
User user = new User(1,"fanqi","123456",1);
//构建一个索引
Index index = new Index.Builder(user).index("coreqi").type("user").build();
//执行
DocumentResult result =jestClient.execute(index);
return result.getJsonString();
} public String search() throws IOException {
String searchJson = "{\n" +
" \"query\": {\n" +
" \"match\": {\n" +
" \"UserName\": \"fanqi\"\n" +
" }\n" +
" }\n" +
"}";
//构建一个搜索
Search search = new Search.Builder(searchJson).addIndex("coreqi").addType("user").build();
//执行
SearchResult result = jestClient.execute(search);
return result.getJsonString();
}

SpringBoot整合Jest操作ES的更多相关文章

  1. SpringBoot整合SpringDataElasticSearch操作ES

    (1).添加starter依赖 <dependency> <groupId>org.springframework.boot</groupId> <artif ...

  2. SpringBoot整合Easyexcel操作Excel,闲暇之余,让我们学习更多

    关于封面:晚饭后回自习室的路上 Easyexcel 官方文档 Easyexcel | github 前言 最近也是在写的一个小练习中,需要用到这个.趁着这次就将写个整合的Demo给大家. 希望能够让大 ...

  3. kotlin + springboot整合mybatis操作mysql数据库及单元测试

    项目mybatis操作数据库参考: http://how2j.cn/k/springboot/springboot-mybatis/1649.html?p=78908 junit对controller ...

  4. SpringBoot 整合Mybatis操作数据库

    1.引入依赖: <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId> ...

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

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

  6. 【Es】jest操作elasticsearch

    https://blog.csdn.net/niuchenliang524/article/details/82869319 操作es的客房端有多个,在此例出三种(具体区别自行百度),本文讲的是jes ...

  7. SpringBoot整合Elasticsearch详细步骤以及代码示例(附源码)

    准备工作 环境准备 JAVA版本 java version "1.8.0_121" Java(TM) SE Runtime Environment (build 1.8.0_121 ...

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

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

  9. SpringBoot操作ES进行各种高级查询

    SpringBoot整合ES 创建SpringBoot项目,导入 ES 6.2.1 的 RestClient 依赖和 ES 依赖.在项目中直接引用 es-starter 的话会报容器初始化异常错误,导 ...

随机推荐

  1. MT【72】一个不等式

    证明: 评: 可以思考$\frac{1}{(1+b)^2}+\frac{1}{(1+a)^2}$与$\frac{2}{(1+\sqrt{ab})^2}$大小.

  2. MT【4】坐标平移后齐次化

    简答:通过坐标平移可以将A点移到原点,设BC:mx’+ny’=1,联立坐标变换后的椭圆方程和BC,将$\frac{y}{x}$看成斜率k,得到关于k的一元二次方程,由题意两根之积为-1,可得.

  3. Hdoj 1008.Elevator 题解

    Problem Description The highest building in our city has only one elevator. A request list is made u ...

  4. 牛客练习赛 小D的Lemon 解题报告

    小D的Lemon 题意 已知 \[ g(x)=\left\{\begin{matrix} 1&,x=1\\ \sum_{i=1}^qk_i&,otherwise \end{matrix ...

  5. hdu 2577 How to Type(dp)

    Problem Description Pirates have finished developing the typing software. He called Cathy to test hi ...

  6. 省选模拟赛第四轮 B——O(n^4)->O(n^3)->O(n^2)

    一 稍微转化一下,就是找所有和原树差距不超过k的不同构树的个数 一个挺trick的想法是: 由于矩阵树定理的行列式的值是把邻接矩阵数值看做边权的图的所有生成树的边权乘积之和 那么如果把不存在于原树中的 ...

  7. 方法重载(overroad)和方法覆盖(override)------java基础知识总结

    a.什么是方法重载?(同一个类中)方法重载是指在同一个类中,出现方法名相同,参数列表不同的情况. b.什么是方法覆盖?(子父类中)方法覆盖是指在子类中,出现和父类一模一样的方法声明的时候,会运行子类的 ...

  8. 聊一聊docker存储驱动

    目录 镜像的分层特性 容器读写层的工作原理 写时复制 用时配置 Docker存储驱动 AUFS OverlayFS Devicemapper 常用存储驱动对比 AUFS VS OverlayFS Ov ...

  9. promise用法详解

    es6的promise可谓是异步书写的一大福音,过去异步js书写是函数嵌套函数的方式,promise出现后书写异步js代码就变得美观得多了 以前的写法:回调函数不停嵌套 ajax('/banners' ...

  10. OS + Linux RedHat 6 / redhat 6 configuration / configure / autoconf / make / make install

    s These critical programs are missing or too old: as ld http://blog.csdn.net/testcs_dn/article/detai ...