一.创建索引且格式化json输出 加上?pretty 就是格式化输出
然后查看所有索引库
curl -XGET http://localhost:9200/_cat/indices?v
添加数据
curl -H "Content-Type: application/json" -XPUT http://localhost:9200/indexwb2/product/p1?op_type=create -d '{
> "name":"mac",
> "price":20000,
> "description":"苹果笔记本",
> "attr":["computer","高端"]
> }'
如果数据已经存在会报错
curl -H "Content-Type: application/json" -XPUT http://localhost:9200/indexwb2/product/p1/_create -d '{
> "name":"mac",
> "price":20000,
> "description":"苹果笔记本",
> "attr":["computer","高端"]
> }'
这样的方式跟上面一样,数据存在会报错
还有一种设置如果没有数据会自动帮助你创建索引库,
设置完成后就会阻止自动创建索引库
查看数据
curl -XGET http://localhost:9200/aaap/product/p1?pretty
然后只查看source里的部分内容
选择不查看那些内容
修改数据
curl -H "Content-Type: application/json" -XPOST http://localhost:9200/aaap/product/p1/_update?pretty -d '{"doc":
> {"name":"新mac",
> "price":2000,
> "description":"苹果笔记本",
> "attr":["computer","高端"]}
> }'
删除数据
curl -XDELETE http://localhost:9200/aaap/product/p2?pretty
删除索引库
curl -XDELETE http://localhost:9200/aaap?pretty