一、ElasticSearch tutorial demo
example 1. 单机、local、CRUD操作
实现方式:
SpringBoot + ElasticSearch
拷贝的小demo,原文地址:https://www.journaldev.com/18148/spring-boot-elasticsearch
实现的功能:
通过 RestHighLevelClient 对 ElasticSearch 中的document,进行CRUD操作。原文中没实现依据index获取所有document功能,我已经添加好了。还添加了全文检索的功能,以及一些注释。
tutorial demo放在了我个人的github地址中:
https://github.com/lihao5257/elasticSearch-demo.git
验证效果时,需要的memo:
1.确认ES启动:127.0.0.1:9200
2.下面是新加document或是修改是用到的Json:
3.获取所有documents:127.0.0.1:8080/books/allBooks
4.根据ID查询document:127.0.0.1:8080/books/id
推荐一个叫做Postman的工具,使用curl很方面。
二、跟文档学习
地址:https://www.elastic.co/guide/en/elasticsearch/client/java-rest/7.6/java-rest-high.html
参考的文档版本为7.6,选的目前release的最新版本。
里面的文档非常的全面,doucument api,search api,里面关于单次,多次查询,bulk操作,同步异步发送请求,讲解的非常清晰明白,我在这里就不再重新说明了。有不懂的地方,欢迎交流。我看了3个多小时,将客户端3节的api文档看完了,有些东西都是相通的,越看越会发现共同之处。