1、創(chuàng)建模板
PUT _template/test
{
"template": "test*",
"mappings": {
"properties": {
"id": { "type": "integer" },
"name": { "type": "keyword" }
}
}
}
返回值
{
"acknowledged" : true
}
2、測試獲取模板
GET _template/test
返回值
{
"test" : {
"order" : 0,
"index_patterns" : [
"test*"
],
"settings" : { },
"mappings" : {
"properties" : {
"name" : {
"type" : "keyword"
},
"id" : {
"type" : "integer"
}
}
},
"aliases" : { }
}
}
3、刪除模板
DELETE _template/test
返回值
{
"acknowledged" : true
}
4、創(chuàng)建索引
PUT test
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 2
}
}
返回值
{
"acknowledged" : true,
"shards_acknowledged" : true,
"index" : "test"
}
5、查看索引
GET test
返回值
{
"test" : {
"aliases" : { },
"mappings" : {
"properties" : {
"id" : {
"type" : "integer"
},
"name" : {
"type" : "keyword"
}
}
},
"settings" : {
"index" : {
"creation_date" : "1702458256558",
"number_of_shards" : "3",
"number_of_replicas" : "2",
"uuid" : "EnJWQWRRSViuNxiTYoFE3w",
"version" : {
"created" : "7040099"
},
"provided_name" : "test"
}
}
}
}
6、給已有索引增加字段
PUT test/_mapping
{
"properties": {
"is_collect": {
"type": "integer"
}
}
}
返回值
{
"acknowledged" : true
}
再次查看確認即可看到新增的字段
{
"test" : {
"aliases" : { },
"mappings" : {
"properties" : {
"id" : {
"type" : "integer"
},
"is_collect" : {
"type" : "integer"
},
"name" : {
"type" : "keyword"
}
}
},
"settings" : {
"index" : {
"creation_date" : "1702458256558",
"number_of_shards" : "3",
"number_of_replicas" : "2",
"uuid" : "EnJWQWRRSViuNxiTYoFE3w",
"version" : {
"created" : "7040099"
},
"provided_name" : "test"
}
}
}
}
7、給新增字段初始值
示例中更沒有加任何篩選條件,默認是全部數(shù)據(jù)初始化值為2
修改數(shù)據(jù)請慎重?。。。。?!
POST test/_update_by_query
{
"script": {
"source": "ctx._source.is_collect = 2"
},
"query": {
"match_all": {}
}
}
返回值
{
"took" : 4,
"timed_out" : false,
"total" : 0,
"updated" : 0,
"deleted" : 0,
"batches" : 0,
"version_conflicts" : 0,
"noops" : 0,
"retries" : {
"bulk" : 0,
"search" : 0
},
"throttled_millis" : 0,
"requests_per_second" : -1.0,
"throttled_until_millis" : 0,
"failures" : [ ]
}
8、刪除索引
DELETE test
返回值
{
"acknowledged" : true
}
總結(jié)
Elasticsearch和Kibana是一對非常強大的開源工具,用于構(gòu)建實時搜索和分析平臺。
-
Elasticsearch是一個分布式的實時搜索和分析引擎,基于Lucene庫開發(fā)而成。它可以存儲、搜索和分析大規(guī)模的文檔數(shù)據(jù),并提供高性能的實時查詢和聚合功能。
-
Kibana是一個用于可視化和管理Elasticsearch數(shù)據(jù)的開源工具。它提供了豐富的圖表、儀表盤和搜索界面,幫助用戶更好地理解和分析數(shù)據(jù)。
-
安裝和配置:首先,需要安裝并配置Elasticsearch和Kibana。它們都可以通過官方網(wǎng)站下載并按照安裝指南進行安裝。安裝完成后,需要配置Elasticsearch和Kibana之間的連接。
-
數(shù)據(jù)索引和搜索:使用Elasticsearch的API,可以將數(shù)據(jù)索引到Elasticsearch中。索引是一個邏輯上的數(shù)據(jù)集合,可以根據(jù)需求定義索引的結(jié)構(gòu)和字段類型。一旦數(shù)據(jù)被索引到Elasticsearch中,就可以使用全文搜索和過濾器查詢數(shù)據(jù)。
-
數(shù)據(jù)聚合和分析:Elasticsearch提供了豐富的聚合功能,可以對數(shù)據(jù)進行統(tǒng)計、分組和計算。聚合可以用于生成各種指標、匯總數(shù)據(jù)和生成可視化圖表。
-
Kibana可視化:通過Kibana的用戶界面,可以創(chuàng)建儀表盤、圖表和搜索界面來展示和分析Elasticsearch中的數(shù)據(jù)。Kibana提供了直觀的圖形化工具,幫助用戶輕松地構(gòu)建漂亮的可視化報表。
-
監(jiān)控和警報:Elasticsearch和Kibana也可以用于監(jiān)控和警報??梢栽O(shè)置警報規(guī)則,以便在達到特定條件時接收警報通知。
-
擴展性和高可用性:Elasticsearch可以輕松擴展到多個節(jié)點,以提供更大的存儲容量和查詢吞吐量。通過配置復制和分片機制,可以實現(xiàn)數(shù)據(jù)的高可用性和故障轉(zhuǎn)移。文章來源:http://www.zghlxwxcb.cn/news/detail-793038.html
總結(jié)起來,Elasticsearch和Kibana是一對強大的開源工具,用于構(gòu)建實時搜索和分析平臺。通過索引、搜索、聚合和可視化等功能,可以輕松地處理和分析大規(guī)模的數(shù)據(jù)集。它們的易用性和靈活性使得開發(fā)者和分析師能夠快速構(gòu)建強大的搜索和分析應用程序。文章來源地址http://www.zghlxwxcb.cn/news/detail-793038.html
到了這里,關(guān)于輕松學會Elasticsearch+kibana的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!