【ElasticSearch】索引:创建、更新、删除

【ElasticSearch】索引:添加、更新、删除

======================================================================

1、创建

2、更新

3、删除

4、关闭打开

======================================================================

索引

1、创建

设置、映射、别名

PUT /myindex
{
  "settings": {
    "index": {
      "number_of_shards": 3,
      "number_of_replicas": 2
    }
  },
  "mappings": {
    "properties": {
      "age": {
        "type": "integer"
      },
      "title": {
        "type": "text",
        "fields": {
          "raw": {
            "type": "keyword"
          }
        }
      }
    }
  },
  "aliases": {
    "myindex_alias": {}
  }
}
仅映射
PUT /myindex2
{
  "mappings": {
    "properties": {
      "age": {
        "type": "integer"
      }
    }
  }
}

 

2、更新

单个更新

PUT /publications

PUT /publications/_mapping
{
  "properties": {
    "title": {
      "type": "text"
    }
  }
}

 

多个更新

# Create the two indices
PUT /my-index-000001
PUT /my-index-000002

# Update both mappings
PUT /my-index-000001,my-index-000002/_mapping
{
  "properties": {
    "user": {
      "properties": {
        "name": {
          "type": "keyword"
        }
      }
    }
  }
}

 

添加新属性到现有的对象字段

PUT /myindex2
{
  "mappings": {
    "properties": {
      "name": {
        "properties": {
          "first": {
            "type": "text"
          }
        }
      }
    }
  }
}

PUT /myindex2/_mapping
{
  "properties": {
    "name": {
      "properties": {
        "last": {
          "type": "text"
        }
      }
    }
  }
}

 

 

3、删除

DELETE get-together

4、关闭打开

POST get-together/_close
POST get-together/_open
posted @ 2021-02-21 15:08  翠微  阅读(417)  评论(0编辑  收藏  举报