2019-06-18 es培训

HEAD _template/twi-tpl
DELETE _template/twi-tpl*
PUT _template/twi-tpl
{
"index_patterns":["twi*"],
"order": 0,
"settings":{
"number_of_shards": 3
},
"mappings":{
"_source":{
"enabled": false
},
"properties":{
"user":{
"type":"keyword"
},
"age":{
"type": "integer"
}
}
}
}

PUT _template/twi-tpl2
{
"index_patterns":["twit*"],
"order":1,
"settings":{
"number_of_shards": 1
},
"mappings":{
"_source":{
"enabled": true
},
"properties":{
"name":{
"properties": {
"firstname":{
"type":"text"
},
"lastname":{
"type":"text"
}
}
}
}
}
}

GET _cat/indices?v
DELETE twit*

PUT twitter
GET twitter/_mapping
GET twitter/_settings
PUT twitter/_doc/1
{
"user":"kimchy",
"post_date":"2009-11-15T14:12:12",
"message":"trying out Elasticsearch"
}
PUT twitter/_doc/1
{
"user":"kimchy",
"post_date":"2010-11-15T14:12:12",
"message":"trying out Elasticsearch"
}
PUT twitter/_doc/1?op_type=create
{
"user":"kimchy",
"post_date":"2011-11-15T14:12:12",
"message":"trying out Elasticsearch"
}
PUT twitter/_create/1
{
"user":"kimchy",
"post_date":"2012-11-15T14:12:12",
"message":"trying out Elasticsearch"
}
POST twitter/_update/1
{
"doc":{
"user":"kimchy",
"post_date":"2013-11-15T14:12:12",
"message":"trying out Elasticsearch"
}
}
POST twitter/_update/1
{
"doc":{
"age":39
}
}
POST twitter/_update/3
{
"doc":{
"age":39
},
"doc_as_upsert":true
}
GET twitter/_doc/2
GET twitter/_doc/1?_source=false
GET twitter/_doc/1?_source=.user
GET twitter/_doc/1?_source=
user

PUT twitter/_doc/2
{
"counter":1,
"tags":["red"]
}
POST twitter/_update/2
{
"script":{
"source": "ctx._source.tags.add(params.tag)",
"lang": "painless",
"params":{
"tag":"blue"
}
}
}
POST twitter/_update/2
{
"script":{
"source": "if(ctx._source.tags.contains(params.tag)){ctx._source.tags.remove(ctx._source.tags.indexOf(params.tag))}",
"lang": "painless",
"params":{
"tag":"blue"
}
}
}
POST twitter/_update/2
{
"script":{
"source": "ctx._source.counter+=params.count",
"lang": "painless",
"params":{
"count":4
}
},
"upsert":{
"couter":1
}
}
HEAD /twitter/_doc/2
DELETE /twitter/_doc/2

DELETE twitter*
GET _cat/indices
PUT twitter
{
"settings": {
"number_of_replicas": 2,
"number_of_shards": 3
},
"mappings": {
"properties": {
"user":{
"type":"keyword"
},
"age":{
"type": "text"
}
}
}
}

POST _bulk
{"index":{"_index":"test", "_id":1}}
{"field1":"value1"}
{"update":{"_id":"1", "_index":"test"}}
{"doc":{"field2":"value2"}}

GET twitter/_doc/2
GET twitter/_mapping
GET twitter/_settings

PUT twitter/_doc/1
{
"user":"kimchy",
"age": "32"
}
PUT twitter/_doc/2
{
"user":"two",
"age":"26"
}
POST twitter/_update/2
{
"doc":{
"age":"31"
}
}

PUT twitter2
GET twitter/_mapping
GET twitter/_settings
DELETE twitter2/_doc/1
POST _reindex
{
"conflicts": "proceed",
"source": {
"index": "twitter"
},
"dest": {
"index":"twitter2",
"version_type": "external"
}
}
PUT twitter2/_doc/2
{
"user":"two",
"age":"27"
}
POST twitter2/_update/2
{
"doc":{
"user": "two",
"age": 30
}
}
GET twitter2/_doc/2
GET twitter2/_mapping
GET twitter2/_settings

PUT twitter/_mapping
{
"properties": {
"email": {
"type": "keyword"
},
"user":{
"type": "text"
}
}
}

GET _cat/aliases?v

GET _cat/allocation?v

PUT twitter
{
"settings": {
"index":{
"number_of_shards" : 8,
"number_of_replicas" : 2
}
}
}

GET twitter

GET _cat/allocation

PUT /twitter/_settings
{
"settings":{
"index.routing.allocation.require._name": "skadoosh-xbuntu",
"index.blocks.write": true
}
}

PUT /twitter/_doc/1
{
"name": "kimchy",
"age":28
}

HEAD /twitter/_doc/2

PUT /twitter/_doc/2
{
"name": "too",
"age": 30
}

PUT /twitter/_doc/3
{
"name": "third",
"age": 31
}

PUT /twitter/_doc/4
{
"name": "four",
"age": 27
}

GET twitter2/_doc/2

GET /_cat/indices

HEAD /twitter2/_doc/1
GET /twitter2/_doc/1

PUT /twitter2/_doc/5
{
"name": "fifth",
"age": 29
}

HEAD /twitter/_doc/5

HEAD /twitter2/_doc/5

POST twitter/_shrink/twitter2
{
"settings":{
"index.number_of_replicas": 1,
"index.number_of_shards": 1,
"index.codec": "best_compression",
"index.routing.allocation.require._name":null,
"index.blocks.write":null
},
"aliases":{
"my_search_indices":{}
}
}

PUT twitter2/_settings
{
"settings":{
"index.blocks.write": true
}
}

PUT twitter2/_doc/9
{
"name": "nine",
"age": 26
}

POST twitter2/_split/twitter3
{
"settings":{
"index.number_of_shards": 5,
"index.blocks.write": null
},
"aliases":{
"my_search_indices":{}
}
}

GET twitter
GET twitter2
GET twitter3

PUT my_logs_index-000001
{
"aliases":{
"logs":{"is_write_index": true}
}
}

DELETE my_logs_index-*
DELETE my_logs_index-000002
DELETE my_logs_index-000003

HEAD my_logs_index-000003

PUT /logs/_doc/1
{
"message": "a dummy log"
}

GET /logs/_doc/1

POST /logs/_rollover
{
"conditions": {
"max_docs": 1
}
}

POST logs/_refresh

PUT /logs/_doc/2
{
"message": "a newer log"
}

PUT /logs/_doc/3
{
"message": "aa new log"
}

POST logs/_refresh

GET /my_logs_index-000001/_doc/3
GET /logs/_doc/2
GET /_cat/indices
POST logs/_refresh

POST /logs/_rollover
{
"conditions": {
"max_docs": 1
}
}

PUT /logs/_doc/2
{
"message": "a newer log"
}

GET _cat/indices/twi*
GET _cat/allocation

HEAD twitter3/_doc/5

GET twitter3/_doc/5

GET twitter2/_doc/5

GET twitter/_doc/1
GET twitter2/_doc/1
GET twitter3/_doc/1

HEAD twitter0
DELETE twitter0
PUT twitter0
{
"mappings": {
"properties":{
"name":{
"properties":{
"first":{
"type": "text"
}
}
},
"user_id":{
"type": "keyword"
}
}
}
}

POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter0",
"alias": "alias1"
}
}
]
}

GET _cat/aliases

POST /_aliases
{
"actions": [
{
"remove": {
"index": "twitter0",
"alias": "alias1"
}
}
]
}

POST /_aliases
{
"actions": [
{
"add": {
"index": "twitter0",
"alias": "alias1",
"filter": {
"term": {
"user": "kimchy"
}
}
}
},
{
"add":{
"index": "twitter0",
"alias": "write_twitter0",
"is_write_index": true
}
}
]
}

GET twitter0/_mapping
GET twitter0/_mapping/field/user_id

PUT twitter0/_mapping
{
"properties": {
"name":{
"properties": {
"last": {
"type": "text"
}
}
},
"user_id":{
"type": "keyword",
"ignore_above": 100
}
}
}

HEAD twitter2
HEAD twitter

GET /twitter/_doc/1

GET _cat/nodes

HEAD twitter

POST /twitter/_close

POST /twitter/_open

HEAD /twitter/_doc/1

GET /twitter/_doc/1

DELETE twitter

PUT twitter
{
"aliases": {
"alias_1": {},
"alias_2":{
"filter": {
"term": {
"user": "kimchy"
}
},
"routing": "kimchy"
}
}
}

GET /_cat/indices/twitter?v&s=index

PUT twitter
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2
}
}

DELETE twitter

GET _search
{
"query": {
"match_all": {}
}
}

GET /_mget
{
"docs" : [
{
"_index" : "customers",
"_id" : "1"
},
{
"_index" : "customers",
"_id" : "2"
}
]
}

GET /customers/_mget
{
"docs" : [
{
"_id" : "1"
},
{
"_id" : "2"
}
]
}

GET /customers/_mget
{
"docs" : [
{
"_id" : "1",
"_source" : ["balance"]
},
{
"_id" : "2",
"stored_fields" : ["city"]
}
]
}

GET /_mapping

GET /_mget
{
"docs" : [
{
"_index" : "customers",
"_type" : "_doc",
"_id" : "1",
"stored_fields" : ["field1", "field2"]
},
{
"_index" : "customers",
"_type" : "_doc",
"_id" : "2",
"stored_fields" : ["field3", "field4"]
}
]
}

POST customers/_update_by_query?conflicts=proceed

你可能感兴趣的:(2019-06-18 es培训)