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
複製代碼