Spring 初探(7) elasticSearch

1.下载elasticsearch项目
https://www.elastic.co/downloads/elasticsearch
2.启动命令:elasticsearch
请注意curl由于版本不同,有的需要引号,有的不需要,请根据自己环境,选择
3.客户端tel:
curl 127.0.0.1:9200
{
"name" : "YPNfYXs",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "ZWiUiHiEQqyvRHAGxKNm4A",
"version" : {
"number" : "6.0.1",
"build_hash" : "601be4a",
"build_date" : "2017-12-04T09:29:09.525Z",
"build_snapshot" : false,
"lucene_version" : "7.0.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
4.新建 Index,可以直接向 Elastic 服务器发出 PUT 请求
curl -X PUT localhost:9200/test
返回:{"acknowledged":true,"shards_acknowledged":true,"index":"test"}
5.查询所有索引
curl -X GET http://localhost:9200/_cat/indices?v
返回:
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open test -kXfYM6aR9OTZvm4nsORYQ 5 1 0 0 1.1kb 1.1kb
6.查看所有TYPE
curl localhost:9200/_mapping?pretty=true
7.插入数据
curl -XPUT http://localhost:9200/test/type/1 -d '{
"user" : "test",
"message" : "It is ok"
}'
8.代码
Applicationpropertis:
elasticsearch.esNodes=localhost:9200
elasticsearch.cluster.name=demo-elasticsearch

pom:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
申明:
public interface ElasticSearchRepository extends ElasticsearchRepository<ElastArticle,String> {
}
使用:
@Autowired
ElasticsearchRepository<ElastArticle,String> elasticsearchRepository ;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值