1. Simple use: (versions 6.x and 7.x have differences in building type, take version 7 as an example)
1. Build an index named web_user:
PUT localhost:9200/web_user
{
"mappings": {
"properties": {
"name": { "type": "text" },
"user_name": { "type": "keyword" },
"email": { "type": "keyword" },
"tweeted_at": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss || yyyy-MM-dd || yyyy/MM/dd HH:mm:ss|| yyyy/MM/dd ||epoch_millis"
}
}
}
}
2. Insert data:
POST localhost:9200/web_user/_doc/ (Id is automatically generated and needs to be submitted by post), if you add the parameter ?op_type=create, an error will be reported if it fails.
{
"name": "lisi",
"user_name": "zhangsan",
"email": "[email protected]",
"tweeted_at": "2019-08-20"
}
PUT localhost:9200/web_user/_doc/1 (specify id, update if it exists)
3. Update data:
POST localhost:9200/web_user/_doc/1/_update
{
"doc": {
"name": "lisi",
"user_name": "zhangsanmodify",
"email": "[email protected]",
"tweeted_at": "2019-08-20"
}
}
4. Delete data:
DELETE localhost:9200/web_user/_doc/1
5. View all data:
localhost:9200/web_user/_doc/_search
6. Update index type
6.1: Use scroll to query cursors, use bulk api to create new indexes and rebuild field indexes.
6.2: Use index aliases to easily replace indexes
6.3: After es5, use reindex
https://blog.csdn.net/weixin_37703281/article/details/91049175