Elasticsearch 单模式下API的增删改查操作

时间:2023-12-14 18:50:44
<pre name="code" class="html">Elasticsearch 单模式下API的增删改查操作

http://192.168.32.80:9200/library/

                            PUT

{"settings":{"index":{"number_of_shards":5,"number_of_replicas":1}}}

可以通过GET带商参数settings可以获得该索引详细的配置信息:

http://192.168.32.80:9200/library/_settings/

                                    GET

{"settings":{"index":{"number_of_shards":5,"number_of_replicas":1}}}

返回;

查询

{"query":{"match_all":{}}}
易读
结果转换器?
重复请求
显示选项?
{ "library": {
"settings": {
"index": {
"creation_date": "1469773369469",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "QA72b8YURSSiTFp9P8Klyg",
"version": {
"created": "2030499"
}
}
}
} } ##获取所有索引信息: http://192.168.32.81:9200/_all/_settings/ 查询 {"query":{"match_all":{}}}
易读
结果转换器?
重复请求
显示选项?
{ ".kibana": {
"settings": {
"index": {
"creation_date": "1469525519216",
"number_of_shards": "1",
"number_of_replicas": "1",
"uuid": "6AFgs3DmTxOu2p8Pjr1F6w",
"version": {
"created": "2030499"
}
}
}
},
"nginx_acc": {
"settings": {
"index": {
"creation_date": "1469197120363",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "NrankAbxS0qC2YPbT5iu5g",
"version": {
"created": "2030499"
}
}
}
},
"library": {
"settings": {
"index": {
"creation_date": "1469773369469",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "QA72b8YURSSiTFp9P8Klyg",
"version": {
"created": "2030499"
}
}
}
} } 5.2 API创建,删除索引 索引/类型/id PUT /library/books/1 初始 library
size: 795B (1.55ki)
docs: 0 (0) library 索引 0个文档:
http://192.168.32.81:9200/libary/books/1/ PUT {"titile":"Elasticsearch: The Defintive Guide","name":{"first":"Zachary","last":"Tong"},"publish_date":"2016-07- 29","price":"59.99"} http://192.168.32.81:9200/libary/books/5/
PUT {"price":"59.99"} GET 请求; http://192.168.32.81:9200/ scan/books/2/ GET ##获取_source 获取指定的字段:
http://192.168.32.81:9200/ scan/books/2/?_source=titile GET ##我们更新同一个ID下的文档,可以通过覆盖的方式更新: http://192.168.32.81:9200/
library/books/1 PUT {"titile":"Elasticsearch: The Defintive Guide","name":{"first":"Zachary","last":"Tong"},"publish_date":"2016-07- 29","price":"99.99"} ##或者通过_update API的方式更新你想要的字段: http://192.168.32.81:9200/ library/books/1_update PUT {"doc":{
"price":10
}
} 获取 :索引/类型/id /libarary/books下的所有id Elasticsearch 的内置字段以及类型 内置字段: _uid,_id,_type,_source,_all,_analyzer,_boost,_parent,_routing,_index,_size,_timestamp,_ttl