elasticsearch 是面向文档的,文档是全部可搜索数据的最小单位html
例如:数据库
文档会被序列化为JSON格式,保存在Elasticsearch中json
每一个文档都有一个Unique IDapi
movieId,title,genres
1,Toy Story(1995),AdvenTure|Animation|Children|Comedy|Fantasy
复制代码
{
"year" : 1995,
"@version" : 1,
"genres" : [
"AdvenTure","Animation",
"Children","Comedy","Fantasy"
],
"id" : "1",
"title" : "Tony Story"
}
复制代码
{
"_index" : "movies",
"_type" : "_doc",
"_id" : "1",
"_score" : "14.626",
"_source" : {
"year" : 1995,
"@version" : 1,
"genres" : [
"AdvenTure","Animation",
"Children","Comedy","Fantasy"
],
"id" : "1",
"title" : "Tony Story"
}
}
复制代码
{
"movies" : {
"settings" : {
"index" : {
"create_date" : "15526261177",
"number_of_shards" : "2",
"number_of_replicas" : "0",
"uuid" : "",
"verison" : {
"created" : "302302"
},
"provided_name" : "movies"
}
}
}
}
复制代码
Index 相关 APIbash
#查看索引相关信息
GET kibana_sample_data_ecommerce
#查看索引的文档总数
GET kibana_sample_data_ecommerce/_count
#查看前10条文档,了解文档格式
POST kibana_sample_data_ecommerce/_search
{
}
#_cat indices API
#查看indices
GET /_cat/indices/kibana*?v&s=index
#查看状态为绿的索引
GET /_cat/indices?v&health=green
#按照文档个数排序
GET /_cat/indices?v&s=docs.count:desc
#查看具体的字段
GET /_cat/indices/kibana*?pri&v&h=health,index,pri,rep,docs.count,mt
#How much memory is used per index?
GET /_cat/indices?v&h=i,tm&s=tm:desc
复制代码
RDBMS | Elasticsearch |
---|---|
Table | Index(Type) |
Row | Document |
Column | Field |
Schema | Mapping |
SQL | DSL |
传统关系型数据库和Elasticsearch的区别app
一些基本的APIless
在kibana的 开发工具
中运行elasticsearch
// 查看索引相关信息
GET kibana_sample_data_ecommerce
// 查看索引的文档总数
GET kibana_sample_data_ecommerce/_count
// 查看前10条文档,了解文档格式
POST kibana_sample_data_ecommerce/_search
{
}
//_cat indeices API
// 查看indices
GET /_cat/indices/kibana*?v&s=index
// 查看状态为绿的索引
GET /_cat/indices?v&health=green
// 查看文档个数排序
GET /_cat/indices?v&s=docs.count:desc
// 查看具体的字段
GET /_cat/indices/kibana*?pri&h=health,index,pri,rep,docs.count,mt
// 每一个索引所占的内存空间
GET /_cat/indices?v&h=i,tm&s=tm:desc
复制代码