Elasticsearch 索引的增,删,查操作:
创建helloworld 索引 两个主分片,两个副本分片的索引
请求:
http://10.xxx.170.xxx:9200/helloworld/ PUT
参数:
{"setting":{"index":{"number_of_shards":2,"number_of_replicas":2}}}
可以简写:
{"setting":{"number_of_shards":2,"number_of_replicas":2}}
响应:
{"acknowledged": true}
可以通过 update-index-settings API 修改settings信息 完成对副本数量的修改。
例如:
请求:
PUT http://10.xxx.xxx.175:9200/helloworld/_settings
参数:
{"number_of_replicas":3}
响应:
{ "acknowledged":true}
创建自定义字段类型的例子如下:创建一个名为 helloInfo类型,类型中有一个字段,字段的名称是 hello,字段的类型是String,字段是不进行分析的。
请求:http://10.xxx.xxx.175:9200/helloworld
参数:
{
"setting": {
"index": {
"number_of_shards": 2,
"number_of_replicas": 2
}
},
"mappings": {
"helloInfo": {
"properties": {
"hello": {
"type": "String",
"index": "not_analyzed"
}
}
}
}
}
请求:http://10.xxx.xxx.175:9200/helloworld/ delete
请求: http://10.xxx.xxx.175:9200/helloworld/ GET
响应:
{
"helloworld": {}
"index": {}
"created": "2040599"
"creation_date": "1500967482864",
"number_of_shards": "5",
"number_of_replicas": "1",
"uuid": "XtdpJ1r1QlSxv1lxCNRDXA",
"version": {}
"helloInfo": {}
"hello": {}
"type": "string",
"index": "not_analyzed"
"properties": {}
"aliases": { },
"mappings": {},
"settings": {},
"warmers": { }
}