elasticsearch 索引操作
Posted ithubb
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了elasticsearch 索引操作相关的知识,希望对你有一定的参考价值。
集群的运行状况
GET /_cat/health?v
获取集群中的节点列表
GET /_cat/nodes?v
列出所有索引
GET /_cat/indices?v
创建索引 指定参数
PUT twitter
{
"settings" : {
"index" : {
"number_of_shards" : 3,
"number_of_replicas" : 2
}
}
}
PUT test { "settings" : { "number_of_shards" : 1 }, "mappings" : { "_doc" : { "properties" : { "field1" : { "type" : "text" } } } } }
删除索引
DELETE /goods
创建文档
put /customer/_doc/1?pretty
{
"name":"hahh",
"age":10
}
POST /customer/_doc
{
"list":"uyuu",
"age":23
}
查询文档
GET /customer/_doc/1?pretty
修改文档
PUT /customer/_doc/1
{
"age":56
}
POST /customer/_doc/1/_update
{
"doc":{
"name":"name"
}
}
删除文档
DELETE /customer/_doc/1?pretty
批量添加
POST /customer/_doc/_bulk
{"index":{"_id":3}}
{"name":"lilin"}
{"index":{"_id":4}}
{"name":"limen"}
批量修改和删除
POST /customer/_doc/_bulk
{"update":{"_id":3}}
{"doc":{"name":"lilin123"}}
{"delete":{"_id":4}}
批量获取多条数据
GET /customer/_doc/_mget
{
"ids":[1,2,3]
}
搜索
POST /customer/_doc/_bulk
{"index":{"_id":1}}
{"name":"lilan","age":10,"sex":1}
{"index":{"_id":2}}
{"name":"huandan","age":11,"sex":2}
{"index":{"_id":3}}
{"name":"miaomiao","age":12,"sex":1}
搜索所有
GET /customer/_doc/_search
通过名字带 miaomiao 的
get /customer/_doc/_search?q=name:miaomiao
查询所有
GET /customer/_doc/_search
{
"query":{
"match_all":{}
}
}
以上是关于elasticsearch 索引操作的主要内容,如果未能解决你的问题,请参考以下文章
Elasticsearch7.8.0版本入门——JavaAPI操作(索引操作)
Elasticsearch7.8.0版本入门——JavaAPI操作(索引操作)
「必备技能」Elasticsearch索引全生命周期管理(附代码)