创建和删除索引
使用DevTools
PUT test001
DELETE test001
使用curl
curl -X PUT "http://10.5.145.101:9200/productindex"
curl -X DELETE "http://10.5.145.101:9200/productindex"
注意索引名称都是小写字母才行。
- 创建type和对应的映射表
查看
curl -XGET "http://10.5.145.101:9200/trolley/_mapping?pretty"
GET trolley/_mapping?pretty
新建type和对应的mapping
DEVTools
POST trolley/product/_mapping?pretty
{
"product": {
"properties": {
"price": {
"type": "double"
},
"onSale": {
"type": "boolean"
},
"type": {
"type": "integer"
},
"createDate": {
"type": "date"
}
}
}
}
注意,ES高版本中不再支持String,请不要在写Spring了。
增量修改mapping
POST trolley/product/_mapping?pretty
{
"product": {
"properties": {
"amount":{
"type":"text"
}
}
}
}
ES不支持非增量修改index,如果要修改,只能删除然后重建。
简单查询
POST /trolley/_search
{
"query": { "match": { "eventType": "ISSUE" } }
}