64 lines
1.0 KiB
JavaScript
64 lines
1.0 KiB
JavaScript
// Test _ 2
|
|
|
|
PUT /users
|
|
{
|
|
"mappings": {
|
|
"properties": {
|
|
"username": {
|
|
"type": "text"
|
|
},
|
|
"age": {
|
|
"type": "integer"
|
|
},
|
|
"password": {
|
|
"type": "integer"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Create Index
|
|
|
|
POST /users/_doc
|
|
{
|
|
"username": "admin",
|
|
"age": 15,
|
|
"password": 123
|
|
}
|
|
// Add a admin User
|
|
|
|
POST /users/_doc
|
|
{
|
|
"username": "Ali",
|
|
"age": 20,
|
|
"password": 32432
|
|
}
|
|
// Add a new User
|
|
|
|
POST /users/_doc
|
|
{
|
|
"username": "reza",
|
|
"age": 35,
|
|
"password": 907897568
|
|
}
|
|
// Add a new User
|
|
|
|
GET /users/_count
|
|
|
|
|
|
// This site is for teenagers and we want to remove all people over 20
|
|
// این سایت برای نوجوانان است و ما می خواهیم همه افراد بالای 20 سال را حذف کنیم
|
|
|
|
|
|
POST /users/_delete_by_query
|
|
{
|
|
"query": {
|
|
"range" : {
|
|
"age" : {
|
|
"gte" : 20
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// Deleting all users over the age of 20
|
|
|
|
GET /users/_count |