3.2_springBoot2.1.x检索之JestClient操作ElasticSearch
这里介绍Jest方式交互,
导入jest版本
<!--导入jest-->
<dependency>
<groupId>io.searchbox</groupId>
<artifactId>jest</artifactId>
<version>6.3.1</version>
</dependency>
application.yml配置
#配置jest
spring:
elasticsearch:
jest:
uris: http://Ip:9200
测试:
@RunWith(SpringRunner.class)
@SpringBootTest
public class Springboot03ElasticsearchApplicationTests {
//自动注入jest
@Autowired
JestClient jestClient;
//jest
@Test
public void contextLoads() {
//1、给Es中索引(保存)一个文档
Article article = new Article();
article.setId(1);
article.setTitle("java入门到放弃");
article.setAuthor("jiatp");
article.setContent("测试内容");
//2、构建一个索引功能 type(类型名字)
Index build = new Index.Builder(article).index("jiatp").type("news").build();
try {
//3、执行
jestClient.execute(build);
} catch(IOException e) {
e.printStackTrace();
}
}
}
//测试搜索
@Test
public void testSearch(){
String json = "{\n" + " \"query\" : {\n" + " \"match\" : {\n"
+ " \"content\" : \"测试内容\"\n" + " }\n"
+ " }\n" + "}";
//构建搜索
Search search = new Search.Builder(json).addIndex("jiatp").addType("news").build();
try {
SearchResult result = jestClient.execute(search);
System.out.println(result.getJsonString());
} catch(IOException e) {
e.printStackTrace();
}
}
dfsdsf
3.2_springBoot2.1.x检索之JestClient操作ElasticSearch的更多相关文章
- ELK-全文检索技术-kibana操作elasticsearch
前言:建议kibana语法一定要学好! 1 软件安装 1.1 ES的安装 第一步:解压压缩包,放到一个没有中文没有空格的位置 第二步:修改配置文件 1. jvm.options ...
- 使用Java High Level REST Client操作elasticsearch
Java高级别REST客户端(The Java High Level REST Client)以后简称高级客户端,内部仍然是基于低级客户端.它提供了更多的API,接受请求对象作为参数并返回响应对象,由 ...
- 使用Java客户端操作elasticsearch(二)
承接上文,使用Java客户端操作elasticsearch,本文主要介绍 常见的配置 和Sniffer(集群探测) 的使用. 常见的配置 前面已介绍过,RestClientBuilder支持同时提供一 ...
- elk快速入门-在kibana中如何使用devtools操作elasticsearch
在kibana中如何使用devtools操作elasticsearch:前言: 首先需要安装elasticsearch,kibana ,下载地址 https://www.elastic.co/cn/d ...
- jest操作 Elasticsearch
package com.lgmall.search; import com.lgmall.search.esEntity.Article;import com.lgmall.search.esEnti ...
- Go操作Elasticsearch
文章转自 Elasticsearch Elasticsearch 下载 https://www.elastic.co/cn/start 运行 解压后cd到解压目录 ./bin/elasticsea ...
- Java操作Elasticsearch 之 [Java High Level REST Clientedit]
1. 简述 Elasticsearch 是基于 Lucene 开发的一个分布式全文检索框架,向 Elasticsearch 中存储和从 Elasticsearch 中查询,格式是json. 向 Ela ...
- GO学习-(31) Go语言操作Elasticsearch
Elasticsearch 本文简单介绍了ES.Kibana和Go语言操作ES. Elasticsearch 介绍 Elasticsearch(ES)是一个基于Lucene构建的开源.分布式.REST ...
- 使用curl命令操作elasticsearch
使用curl命令操作elasticsearch 大岩不灿 发表于 2015年4月25日 浏览 7,426 次 第一:_cat系列_cat系列提供了一系列查询elasticsearch集群状态的接口.你 ...
随机推荐
- [Catalan数三连]网格&有趣的数列&树屋阶梯
如何让孩子爱上打表 Catalan数 Catalan数是组合数学中一个常出现在各种计数问题中的数列. 以比利时的数学家欧仁·查理·卡塔兰 (1814–1894)的名字来命名. 先丢个公式(设第n项为$ ...
- 前台处理ajax:axios
""" 1.安装axios cnpm install axios --save 2.src/main.js配置 // 允许ajax发送请求时附带cookie axios. ...
- 服务器安装TeamViewer 13
服务器安装TeamViewer 13 服务器上安装TeamViewer,网上找了个教程开始安装,里面有坑,安装时要根据自己的情况而定.Linux系统更新太快,网上教程可能会有一些出入. TeamVie ...
- linux下根据根据进程号查端口、根据端口号查进程号汇总,以及netstat的相关资料(工作中匮乏的知识)
根据端口查进程: lsof -i:port netstat -nap | grep port 根据进程号查端口: lsof -i|grep pid netstat -nap | grep pid 根据 ...
- LaTex 插入图像,以及应用表格
插入图像 参考:http://www.ctex.org/documents/latex/graphics/ 1: \includegraphics[width=20mm]{head.png} 应用表格 ...
- 深入理解JAVA虚拟机原理之Dalvik虚拟机(三)
更多Android高级架构进阶视频学习请点击:https://space.bilibili.com/474380680 本文是Android虚拟机系列文章的第三篇,专门介绍Andorid系统上曾经使用 ...
- http://localhost:8080 is requesting your username and password
after you startup your tomcat, you type a concrete request url in broswer, the tomcat probably wil ...
- 提供免费可商用的优秀背景视频素材——COVERR
现在经常看到很多网站都是贴近更现代化的设计,首页都会放置跟网站内容相关的视频短片作为背景,不用按下播放按钮,就有动态显示效果,跟以往静态图片相较下更动态.更有活力,对网站的视觉体验有一定的提升作用.但 ...
- 2019-9-18-WPF-客户端开发需要知道的触摸失效问题
title author date CreateTime categories WPF 客户端开发需要知道的触摸失效问题 lindexi 2019-09-18 15:30:38 +0800 2019- ...
- bzoj3143 游走 期望dp+高斯消元
题目传送门 题意: 一个无向连通图,顶点从1编号到N,边从1编号到M. 小Z在该图上进行随机游走,初始时小Z在1号顶点,每一步小Z以相等的概率随机选 择当前顶点的某条边,沿着这条边走到下一个顶点,获得 ...