elasticsearch基本CURD方法及示例

一.索引添加、删除、修改

  • 添加语法

PUT /my_index
{
    "settings": { ... any settings ... },
    "mappings": {
        "type_one": { ... any mappings ... },
        "type_two": { ... any mappings ... },
        ...
    }
}
  • 创建索引的示例

PUT /my_index
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": 0
  },
  "mappings": {
    "my_type": {
      "properties": {
        "my_field": {
          "type": "text"
        }
      }
    }
  }
}



curl -XPUT '192.168.127.98:9200/my_index?pretty' -d '{   "settings": {     "number_of_shards": 1,     "number_of_replicas": 0   },   "mappings": {     "my_type": {       "properties": {         "my_field": {           "type": "text"         }       }     }   } }'
  • 查看所有索引

  • 修改索引

  • 删除索引

二、文档的添加、删除、修改

  • 添加文档语法

  • 添加文档

  • 获取所有文档

Last updated

Was this helpful?