1)创建索引
PUT /{索引名称}
{ "settings": { "number_of_shards": 5, //每个索引的主分片数,默认值是 5 。这个配置在索引创建后不能修改。 "number_of_replicas": 1 //每个主分片的副本数,默认值是 1 。对于活动的索引库,这个配置可以随时修改 } }
修改索引设置的方法:
PUT /{索引名称}/_settings
{ "settings": { "number_of_replicas": 1 //每个主分片的副本数,默认值是 1 。对于活动的索引库,这个配置可以随时修改 } }
2)创建mapping
POST /{索引名称}/{type名称}/_mapping{
"{type名称}": { "properties": { "id": { "type": "integer" }, "cid": { "type": "integer" }, "title": { "type": "text" }, "info": { "type": "text" }, "eudid": { "type": "integer" }, "gender": { "type": "integer" }, "years": { "type": "integer" }, "company_title": { "type": "text" }, "update_time": { "type": "date",
"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
}
}
}
}
查看Mapping
GET /{索引名称}/{type名称}/_mapping
4)添加数据
PUT /{索引名称}/{type名称}/{数据id}
{ "id": "401", "cid": "7", "title": "会计", "info": "一年以上经验", "eduid": "1", "gender": "0", "years": "1", "update_time": "2018-07-28 09:57:27", "company_title": "天睛事务所" }
5)搜索
POST /{索引名称}/{type名称}/_search
{ //搜索条件 }
查询单条数据 GET /{索引名称}/{type名称}/{数据id}
删除单条数据 DELETE /{索引名称}/{type名称}/{数据id}
修改单条数据 POST /{索引名称}/{type名称}/{数据id}
{ "cid": "7", "title": "会计", "info": "一年以上经验", "eduid": "1", "gender": "0", "years": "1", "update_time": "2018-07-28 09:57:27", "company_title": "天睛事务所" }