mysql:database,table,record
ES: index,type,document
ES在6.x版本以后重大变更:一个index只能存在一个type
需要建一个新用户来启动ES,root用户没法启动
安装后没法访问http://安装ES的IP:9200
$ES_HOME/config/下elasticsearch-.yml配置文件 配置下面参数
network.host: xx.xx.xx.xx
http.port: 9200
ERROR: [3] bootstrap checks failed
修改config/elasticsearch.yml
discovery.type: single-node
再启动,启动成功!此时不进行启动检查!## File descriptor check 跳过
要在防火墙中放开9200 9300端口
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9300 -j ACCEPT
参考链接:
https://www.cnblogs.com/yehui/p/9087845.html
https://blog.csdn.net/cool__7/article/details/81136987
ES的启动确认
http://10.138.60.123:9200
ES的健康状态检查
http://10.138.60.123:9200/_cat/health?v
查看ES的索引
http://10.138.60.123:9200/_cat/indices?v
创建ES索引
PUT:http://10.138.60.123:9200/customer?pretty
插入一条数据
http://10.138.60.123:9200/customer/external/1?pretty
{ "name":"kevin" }
返回
{
"_index": "customer",数据库
"_type": "external",表
"_id": "1",主键
"_version": 1,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": true
}
查询一条记录
get:http://10.138.60.123:9200/customer/external/1?pretty
返回
{ "_index": "customer", "_type": "external", "_id": "1", "_version": 1, "found": true,是否已经找到 "_source": { "name": "kevin" } }
在使用SpringBoot整合Elasticsearch 之前,我们应该了解下它们之间对应版本关系。
x <= 1.3.5 | y <= 1.3.4 | z <= 1.7.2* |
x >= 1.4.x | 2.0.0 <=y < 5.0.0** | 2.0.0 <= z < 5.0.0** |
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-elasticsearch</artifactId> </dependency>
spring.data.elasticsearch.cluster-name=elasticsearch spring.data.elasticsearch.cluster-nodes=xxx.xxx.xxx.xxx:9300 spring.data.elasticsearch.repositories.enabled=true
@Document( indexName = "blog",//要小写 代表数据库 type = "atricle"//要小写 代表表 ) public class Article implements Serializable{ private static final long serialVersionUID=1L; private long id; private String titile; private String summary; private String content; private int pv; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTitile() { return titile; } public void setTitile(String titile) { this.titile = titile; } public String getSummary() { return summary; } public void setSummary(String summary) { this.summary = summary; } public String getContent() { return content; } public void setContent(String content) { this.content = content; } public int getPv() { return pv; } public void setPv(int pv) { this.pv = pv; } }
@Component @Document(indexName = "blog",type="atricle",shards = 1,replicas = 0) public interface ArticleRepository extends ElasticsearchRepository<Article,Long>{ }
@RequestMapping("/es") @RestController public class AtricleController { @Autowired private ArticleRepository repository; @RequestMapping("/save") public String save() { Article article = new Article(); article.setId(1); article.setTitile("nihao"); article.setContent("lalalala"); article.setSummary("66666summary"); article.setPv(9998); repository.save(article); return "success"; } }
添加好面的代码就可以通过url地址访问了
http://localhost:8081/es/save 访问完就在es里添加了一条记录
通过查询到了一个新的数据库也就是一个新的index
http://10.138.60.123:9200/_cat/indices?v
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size yellow open blog 974t88jwRpOXuRFE4SOreQ 5 1 1 0 5.6kb 5.6kb yellow open customer 2u-wByWGQaSugyhKzgZmUQ 5 1 1 0 4.1kb 4.1kb
http://10.138.60.123:9200/blog 查询表结构
{ "blog": { "aliases": {}, "mappings": { "atricle": { "properties": { "content": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "id": { "type": "long" }, "pv": { "type": "long" }, "summary": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } }, "titile": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 } } } } } }, "settings": { "index": { "refresh_interval": "1s", "number_of_shards": "5", "provided_name": "blog", "creation_date": "1552542258282", "store": { "type": "fs" }, "number_of_replicas": "1", "uuid": "974t88jwRpOXuRFE4SOreQ", "version": { "created": "5061599" } } } } }
相关推荐
springboot整合es-springboot-elasticsearch
springboot-elasticsearch API实现,使用spring-boot框架,实现ES查询,新增,删除及批量操作。更新pom及可启动使用,简单方便无烦恼
hello word 最简单的版本 Springboot-web web 版本...Springboot-elasticsearch 与 Elasticsearch 整合 Springboot-i18n SpringBoot 国际化配置 SpringBoot-multi-source SpringBoot 多数据源配置,全局异常自定义处理
springboot-elasticsearch
springboot-elasticsearch-example springboot 与elasticsearch整合
es整合springboot-elasticsearch-demo
【springboot-集成篇】springboot整合ElasticSearch的两种方式(非连接池,附源码)
springboot 整合es-springboot-es
springBoot整合es-springBoot-es
Springboot-Notebook是一系列以springboot为基础的开发框架,整合了Redis , Rabbitmq , ES , MongoDB , sharding-jdbc , zookeeper等互联网主流技术,实现了开发中常见功能点的综合实战性案例。 本着拿来即用的...
基于springboot-es的博客检索系统 结合实际需求分析,打造个人博客检索系统。...3、Mysql数据同步到ES(logstash, mysql binlog, 第三方Go框架) 4、Springboot 整合操作ES 5、ElasticSearch 安装中文分词器
springboot-0.0.1-SNAPSHOT.jar
springboot-elasticsearch-pom文件,可以参考
Idea打开SpringBoot整合es-search搜索引擎例子,es搭建自行百度即可
springboot-es-demo
server','springboot-elasticsearch','springboot-freemarker','springboot-helloworld','springboot-mybatis','springboot-mybatis-annotationspringboot-mybatis-annotation','springboot-mybatis-mutil-...
springboot+layui文件上传demo,本人工作因为项目中使用,自行创建demo。后续将上传excel读取方法easyExcel
演示在springboot中使用java api client操作elasticSearch
springboot-elasticsearch的demo。页面是layui的,需要的话就自己下载把。感谢