SpringBoot 3.x 整合 ElasticSearch 8.x
配置文件修改
shell
spring.elasticsearch.uris=http://192.168.253.101:9200,http://192.168.253.102:9200,http://192.168.253.103:9200准备数据,创建多个索引列表
shell
PUT /shuofeng_shop_v1
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2
},
"mappings": {
"properties": {
"id": {
"type": "keyword"
},
"title": {
"type": "keyword"
},
"summary": {
"type": "text"
},
"price": {
"type": "float"
}
}
}
}shell
PUT /shuofeng_shop_v1/_bulk
{ "index": { "_index": "xdclass_shop_v1" } }
{ "id": "1", "title": "Spring Boot","summary":"this is a summary Spring Boot video", "price": 9.99 }
{ "index": { "_index": "xdclass_shop_v1" } }
{ "id": "2", "title": "java","summary":"this is a summary java video", "price": 19.99 }
{ "index": { "_index": "xdclass_shop_v1" } }
{ "id": "3", "title": "Spring Cloud","summary":"this is a summary Spring Cloud video", "price": 29.99 }
{ "index": { "_index": "xdclass_shop_v1" } }
{ "id": "4", "title": "Spring_Boot", "summary":"this is a summary Spring_Boot video","price": 59.99 }
{ "index": { "_index": "xdclass_shop_v1" } }
{ "id": "5", "title": "SpringBoot","summary":"this is a summary SpringBoot video", "price": 0.99 }常见命令,可以用 postman 访问(网络安全组记得开发端口)
shell
#查看集群健康情况
http://192.168.253.101:9200/_cluster/health
#查看分片情况
http://192.168.253.101:9200/_cat/shards?v=true&pretty
#查看节点分布情况
http://192.168.253.101:9200/_cat/nodes?v=true&pretty
#查看索引列表
http://192.168.253.101:9200/_cat/indices?v=true&pretty
朔风