(1)创建索引
put 192.168.247.197:9200/type2
192.168.247.197:9200/type2
(2)创建映射
post 192.168.247.197:9200/type2/type/_mapping
{ "properties": { "id": { "type": "String" }, "name": { "type": "String" }, "desc": { "type": "String" }, "createtime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" }, "modifiytime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" } } }
注:es 2.3.5上面还没有text这种类型,"type":"text" 改为 "type":"String"即可
在这片文章中介绍了ES2.3.5版本中ES的数据类型:https://www.cnblogs.com/excellencesy/p/11736079.html
(3)添加文档
POST 192.168.247.197:9200/type2/type
{ "id": "002", "name": "zhangsan", "desc": "hahahah", "createtime": "2011-12-17", "modifiytime": "2011-12-11" }
(4)排序查询
get 192.168.247.197:9200/type2/_search
{ "query": { "match": { "name": "zhangsan" } }, "sort": [ { "createtime": { "order": "desc" } } ] }
注:ES中只有数字,日期两种类型的数据可以排序
(5)删除清空索引
delete 192.168.247.197:9200/type2
(6)清空索引中的数据
post 192.168.11.166:9200/language/language/_delete_by_query
{ "query": { "match_all": {} } }