Elastic Search 学习之路(三)—— tutorial demo

一、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:
[
    {
        "author""JournalDev",
        "price"199.1,
        "id""87a3a002-c68a-488b-8172-2510c4be9d41",
        "title""Java Always"
    },
    {
        "author""JournalDev",
        "price"299.1,
        "id""7172b649-4846-47ad-a9d9-6e5b93302c46",
        "title""Lee"
    },
    {
        "author""JournalDev",
        "price"799.1,
        "id""96fe24ee-49fe-48a8-a7df-65866cbda618",
        "title""Song"
    },
    {
        "author""Tom",
        "price"223.4,
        "title""JiM Green"
    },
    {
        "author""Sony Green",
        "price"19.8,
        "title""Harry Poart"
    },
    {
        "author""Sony Green",
        "price"19.8,
        "title""Harry Poart 2"
    },
    {
        "author""Sony Green",
        "price"19.8,
        "title""Harry Poart 3"
    }
]

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文档看完了,有些东西都是相通的,越看越会发现共同之处。

猜你喜欢

转载自www.cnblogs.com/lihao007/p/12552922.html