来自:r6a.cn/cyJw







curl -X PUT "localhost:9200/customer/_doc/1?pretty" -H 'Content-Type: application/json' -d'{"name": "John Doe"}'
curl -X GET "localhost:9200/customer/_doc/1?pretty"
GET /customer/_search?q=*&sort=name:asc&pretty
GET /customer/_search{"query": { "match_all": {} },"sort": [{"name": "asc" }]}


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

PUT twitter{"settings" : {"number_of_shards" : 3,"number_of_replicas" : 2}}
PUT twitter{"settings" : {"index" : {"number_of_shards" : 3,"number_of_replicas" : 2}},"mappings" : {"type1" : {"properties" : {"field1" : { "type" : "text" }}}}}
PUT twitter{"aliases" : {"alias_1" : {},"alias_2" : {"filter" : {"term" : {"user" : "kimchy" }},"routing" : "kimchy"}}}




PUT /twitter/_settings{"index" : {"number_of_replicas" : 2}}
PUT /twitter/_settings{"index" : {"refresh_interval" : null}}
index.blocks.read_only:设为true,则索引以及索引的元数据只可读index.blocks.read_only_allow_delete:设为true,只读时允许删除。index.blocks.read:设为true,则不可读。index.blocks.write:设为true,则不可写。index.blocks.metadata:设为true,则索引元数据不可读写。
PUT _template/template_1{"index_patterns": ["te*", "bar*"],"settings": {"number_of_shards": 1},"mappings": {"type1": {"_source": {"enabled": false},"properties": {"host_name": {"type": "keyword"},"created_at": {"type": "date","format": "EEE MMM dd HH:mm:ss Z YYYY"}}}}}
GET /_template/template_1GET /_template/temp*GET /_template/template_1,template_2GET /_template
DELETE /_template/template_1
POST /my_index/_closePOST /my_index/_open
PUT /my_source_index/_settings{"settings": {<!-- 指定进行收缩的节点的名称 -->"index.routing.allocation.require._name": "shrink_node_name",<!-- 阻止写,只读 -->"index.blocks.write": true}}
POST my_source_index/_shrink/my_target_index{"settings": {"index.number_of_replicas": 1,"index.number_of_shards": 1,"index.codec": "best_compression"}}
GET _cat/recovery?vGET _cluster/health
5 → 10 → 30 (split by 2, then by 3)5 → 15 → 30 (split by 3, then by 2)5 → 30 (split by 6)
PUT my_source_index{"settings": {"index.number_of_shards" : 1,<!-- 创建时需要指定路由分片数 -->"index.number_of_routing_shards" : 2}}
PUT /my_source_index/_settings{"settings": {"index.blocks.write": true}}
POST my_source_index/_split/my_target_index{"settings": {<!--新索引的分片数需符合拆分规则-->"index.number_of_shards": 2}}
GET _cat/recovery?vGET _cluster/health
PUT /logs-000001{"aliases": {"logs_write": {}}}
POST /logs_write/_rollover{"conditions": {"max_age": "7d","max_docs": 1000,"max_size": "5gb"}}
POST /my_alias/_rollover/my_new_index_name{"conditions": {"max_age": "7d","max_docs": 1000,"max_size": "5gb"}}
# PUT /<logs-{now/d}-1> with URI encoding:PUT /%3Clogs-%7Bnow%2Fd%7D-1%3E{"aliases": {"logs_write": {}}}PUT logs_write/_doc/1{"message": "a dummy log"}POST logs_write/_refresh# Wait for a day to passPOST /logs_write/_rollover{"conditions": {"max_docs": "1"}}
PUT /logs-000001{"aliases": {"logs_write": {}}}POST /logs_write/_rollover{"conditions" : {"max_age": "7d","max_docs": 1000,"max_size": "5gb"},"settings": {"index.number_of_shards": 2}}
POST /logs_write/_rollover?dry_run{"conditions" : {"max_age": "7d","max_docs": 1000,"max_size": "5gb"}}
GET /test/_segmentsGET /index1,index2/_segmentsGET /_segments
# return information of only index testGET /test/_shard_stores# return information of only test1 and test2 indicesGET /test1,test2/_shard_stores# return information of all indicesGET /_shard_storesGET /_shard_stores?status=green
POST /kimchy,elasticsearch/_cache/clearPOST /_cache/clear
POST /kimchy,elasticsearch/_refreshPOST /_refresh
POST twitter/_flush
POST /kimchy/_forcemerge?only_expunge_deletes=false&max_num_segments=100&flush=true
POST /kimchy,elasticsearch/_forcemergePOST /_forcemerge
PUT test{<!--映射定义 -->"mappings" : {<!--名为type1的映射类别 mapping type-->"type1" : {<!-- 字段定义 -->"properties" : {<!-- 名为field1的字段,它的field datatype 为 text -->"field1" : { "type" : "text" }}}}}
PUT twitter{"mappings": {"_doc": {"properties": {"type": { "type": "keyword" },"name": { "type": "text" },"user_name": { "type": "keyword" },"email": { "type": "keyword" },"content": { "type": "text" },"tweeted_at": { "type": "date" }}}}}

stringtext and keywordNumeric datatypeslong, integer, short, byte, double, float, half_float, scaled_floatDate datatypedateBoolean datatypebooleanBinary datatypebinaryRange datatypes 范围integer_range, float_range, long_range, double_range, date_range
Array datatype数组就是多值,不需要专门的类型Object datatypeobject :表示值为一个JSON 对象Nested datatypenested:for arrays of JSON objects(表示值为JSON对象数组 )
Geo-point datatypegeo_point:for lat/lon points (经纬坐标点)Geo-Shape datatypegeo_shape:for complex shapes like polygons (形状表示)
IP datatypeip:for IPv4 and IPv6 addressesCompletion datatypecompletion:to provide auto-complete suggestionsToken count datatypetoken_count:to count the number of tokens in a stringmapper-murmur3murmur3:to compute hashes of values at index-time and store them in the indexPercolator typeAccepts queries from the query-dsljoin datatypeDefines parent/child relation for documents within the same index
analyzer 指定分词器normalizer 指定标准化器boost 指定权重值coerce 强制类型转换copy_to 值复制给另一字段doc_values 是否存储docValuesdynamicenabled 字段是否可用fielddataeager_global_ordinalsformat 指定时间值的格式ignore_aboveignore_malformedindex_optionsindexfieldsnormsnull_valueposition_increment_gappropertiessearch_analyzersimilaritystoreterm_vector
PUT my_index{"mappings": {"_doc": {"properties": {"date": {"type": "date",<!--格式化日期 -->"format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"}}}}}
PUT my_index{"mappings": {"_doc": {"properties": {"city": {"type": "text","fields": {"raw": {"type": "keyword"}}}}}}}
PUT my_index/_doc/1{"city": "New York"}PUT my_index/_doc/2{"city": "York"}
GET my_index/_search{"query": {"match": {"city": "york"}},"sort": {"city.raw": "asc"},"aggs": {"Cities": {"terms": {"field": "city.raw"}}}}

PUT data/_doc/1{ "count": 5 }

[ "strict_date_optional_time","yyyy/MM/dd HH:mm:ss Z||yyyy/MM/dd Z"]PUT my_index/_doc/1{"create_date": "2015/09/02"}GET my_index/_mapping
PUT my_index{"mappings": {"_doc": {"dynamic_date_formats": ["MM/dd/yyyy"]}}}
PUT my_index{"mappings": {"_doc": {"date_detection": false}}}
PUT my_index{"mappings": {"_doc": {"numeric_detection": true}}}PUT my_index/_doc/1{"my_float": "1.0","my_integer": "1"}
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69902700/viewspace-3145306/ ,如需转载,请注明出处,否则将追究法律责任。