概括
Elaticsearch,简称为 ES, ES 是一个开源的高扩展的分布式[全文搜索]引擎,Elasticsearch 是面向数据库,一条数据在这里就是一个文档。
基本要素
ES是一个文档型数据库,下面将ES里面涉及到的元素与关系型数据库进行一一对应。
ElasticSearch | 索引(index) | 类型(type) | 文档(document) | 字段(field) |
---|---|---|---|---|
MySQL | 数据库(database) | 数据表(table) | 数据行(row) | 数据列(column) |
索引操作
创建索引(没有mapping)
PUT /student
创建索引(明确mapping),有使用分词器
GET /student
{
"mappings": {
"properties": {
"info": {
"type": "text",
"analyzer": "ik_smart"
},
"email": {
"type": "keyword",
"index": false
},
"name": {
"type": "object",
"properties": {
"firstName": {
"type": "keyword",
"index": false
},
"lastName": {
"type": "keyword",
"index": false
}
}
}
}
}
}
查看所有
GET /student
查看所有索引
GET /_cat/indices
删除索引
DELETE /student
修改索引
PUT /student/_mapping
{
"properties": {
"age": {
"type": "integer"
}
}
}