header
-H 'Content-Type: application/json'

index

  1. PUT /blogs?pretty
  2. {
  3. "settings" : {
  4. "number_of_shards" : 1,
  5. "number_of_replicas" : 0,
  6. "refresh_interval": "1s"
  7. },
  8. "mappings": {
  9. "_doc": {
  10. "properties": {
  11. "title":{
  12. "type":"keyword"
  13. },
  14. "date": {
  15. "type": "date",
  16. "format": "yyyy-MM-dd"
  17. }
  18. }
  19. }
  20. }
  21. }

mapping

已有索引的情况下,设置 mappings,不会影响已有的 mapping

  1. PUT atest/_mapping/_doc
  2. {
  3. "properties": {
  4. "labels": {
  5. "type": "text",
  6. "analyzer": "ik_max_word"
  7. }
  8. }
  9. }

设置时间类型映射(mapping)

format 常用格式
  • yyyy-MM-dd
  • epoch_millis 毫秒时间戳
  • epoch_second 秒时间戳
  • strict_date_optional_time||epoch_millis (multi)
  • yyyy-MM-dd HH:mm:ss||epoch_second

文档

alias

  1. POST /_aliases
  2. {
  3. "actions": [
  4. {
  5. "remove": {
  6. "index": "index",
  7. "alias": "index_2"
  8. }
  9. },
  10. {
  11. "add": {
  12. "index": "index",
  13. "alias": "index_3",
  14. "filter": {
  15. "term":{"flag": 1}
  16. }
  17. }
  18. }
  19. ]
  20. }