91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

elasticsearch索引怎么創建

發布時間:2021-12-16 10:02:42 來源:億速云 閱讀:529 作者:iii 欄目:大數據

本篇內容主要講解“elasticsearch索引怎么創建”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“elasticsearch索引怎么創建”吧!

索引

查看所有索引

rst, _ := client.CatIndices().Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

[
    {
        "health": "yellow",
        "status": "open",
        "index": "user",
        "uuid": "F4eP0Sq-S9a9pBJhN_eYVQ",
        "pri": "1",
        "rep": "3",
        "docs.count": "0",
        "docs.deleted": "0",
        "creation.date": "0",
        "creation.date.string": "",
        "store.size": "208b",
        "pri.store.size": "208b",
        "completion.size": "",
        "pri.completion.size": "",
        "fielddata.memory_size": "",
        "pri.fielddata.memory_size": "",
        "fielddata.evictions": "0",
        "pri.fielddata.evictions": "0",
        "query_cache.memory_size": "",
        "pri.query_cache.memory_size": "",
        "query_cache.evictions": "0",
        "pri.query_cache.evictions": "0",
        "request_cache.memory_size": "",
        "pri.request_cache.memory_size": "",
        "request_cache.evictions": "0",
        "pri.request_cache.evictions": "0",
        "request_cache.hit_count": "0",
        "pri.request_cache.hit_count": "0",
        "request_cache.miss_count": "0",
        "pri.request_cache.miss_count": "0",
        "flush.total": "0",
        "pri.flush.total": "0",
        "flush.total_time": "",
        "pri.flush.total_time": "",
        "get.current": "0",
        "pri.get.current": "0",
        "get.time": "",
        "pri.get.time": "",
        "get.total": "0",
        "pri.get.total": "0",
        "get.exists_time": "",
        "pri.get.exists_time": "",
        "get.exists_total": "0",
        "pri.get.exists_total": "0",
        "get.missing_time": "",
        "pri.get.missing_time": "",
        "get.missing_total": "0",
        "pri.get.missing_total": "0",
        "indexing.delete_current": "0",
        "pri.indexing.delete_current": "0",
        "indexing.delete_time": "",
        "pri.indexing.delete_time": "",
        "indexing.delete_total": "0",
        "pri.indexing.delete_total": "0",
        "indexing.index_current": "0",
        "pri.indexing.index_current": "0",
        "indexing.index_time": "",
        "pri.indexing.index_time": "",
        "indexing.index_total": "0",
        "pri.indexing.index_total": "0",
        "indexing.index_failed": "0",
        "pri.indexing.index_failed": "0",
        "merges.current": "0",
        "pri.merges.current": "0",
        "merges.current_docs": "0",
        "pri.merges.current_docs": "0",
        "merges.current_size": "",
        "pri.merges.current_size": "",
        "merges.total": "0",
        "pri.merges.total": "0",
        "merges.total_docs": "0",
        "pri.merges.total_docs": "0",
        "merges.total_size": "",
        "pri.merges.total_size": "",
        "merges.total_time": "",
        "pri.merges.total_time": "",
        "refresh.total": "0",
        "pri.refresh.total": "0",
        "refresh.external_total": "0",
        "pri.refresh.external_total": "0",
        "refresh.time": "",
        "pri.refresh.time": "",
        "refresh.external_time": "",
        "pri.refresh.external_time": "",
        "refresh.listeners": "0",
        "pri.refresh.listeners": "0",
        "search.fetch_current": "0",
        "pri.search.fetch_current": "0",
        "search.fetch_time": "",
        "pri.search.fetch_time": "",
        "search.fetch_total": "0",
        "pri.search.fetch_total": "0",
        "search.open_contexts": "0",
        "pri.search.open_contexts": "0",
        "search.query_current": "0",
        "pri.search.query_current": "0",
        "search.query_time": "",
        "pri.search.query_time": "",
        "search.query_total": "0",
        "pri.search.query_total": "0",
        "search.scroll_current": "0",
        "pri.search.scroll_current": "0",
        "search.scroll_time": "",
        "pri.search.scroll_time": "",
        "search.scroll_total": "0",
        "pri.search.scroll_total": "0",
        "search.throttled": "false",
        "segments.count": "0",
        "pri.segments.count": "0",
        "segments.memory": "",
        "pri.segments.memory": "",
        "segments.index_writer_memory": "",
        "pri.segments.index_writer_memory": "",
        "segments.version_map_memory": "",
        "pri.segments.version_map_memory": "",
        "segments.fixed_bitset_memory": "",
        "pri.segments.fixed_bitset_memory": "",
        "warmer.current": "0",
        "pri.warmer.current": "0",
        "warmer.total": "0",
        "pri.warmer.total": "0",
        "warmer.total_time": "",
        "pri.warmer.total_time": "",
        "suggest.current": "0",
        "pri.suggest.current": "0",
        "suggest.time": "",
        "pri.suggest.time": "",
        "suggest.total": "0",
        "pri.suggest.total": "0",
        "memory.total": "",
        "pri.memory.total": ""
    }
]

查看 us 開頭的索引

rst, _ := client.CatIndices().Index("us*").Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

同上

查看索引信息

rst, _ := client.IndexGet("user").Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{
    "user": {
        "aliases": {},
        "mappings": {
            "properties": {
                "name": {
                    "type": "keyword"
                }
            }
        },
        "settings": {
            "index": {
                "creation_date": "1599207187635",
                "number_of_replicas": "1",
                "number_of_shards": "1",
                "provided_name": "user",
                "uuid": "F4eP0Sq-S9a9pBJhN_eYVQ",
                "version": { "created": "7080099" }
            }
        },
        "warmers": null
    }
}

查看 mapping

rst, _ := client.GetMapping().Index("user").Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{
    "user": {
        "mappings": {
            "properties": {
                "name": {
                    "type": "keyword"
                }
            }
        }
    }
}

查看 settings

rst, _ := client.IndexGetSettings("user").Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{
    "user": {
        "settings": {
            "index": {
                "creation_date": "1599207187635",
                "number_of_replicas": "1",
                "number_of_shards": "1",
                "provided_name": "user",
                "uuid": "F4eP0Sq-S9a9pBJhN_eYVQ",
                "version": { "created": "7080099" }
            }
        }
    }
}

創建索引

rst, _ := client.CreateIndex("user").Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{ "acknowledged": true, "shards_acknowledged": true, "index": "user" }

創建索引時指定 mapping 和 settings

bd := `{
  "mappings" : {
    "properties" : {
      "name" : {
        "type" : "keyword"
      }
    }
  },
  "settings" : {
    "index" : {
      "number_of_shards" : 1,
      "number_of_replicas" : 2
    }
  }
}`
rst, _ := client.CreateIndex("user").Body(bd).Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println( string(buf))
  • 返回

{ "acknowledged": true, "shards_acknowledged": true, "index": "user" }

創建索引,然后置頂 mapping

_, err := client.CreateIndex("user").Do(ctx)
if err != nil {
    panic(err.Error())
}

bd := `
{
    "properties" : {
      "name" : {
        "type" : "keyword"
      }
    }
}`
rst, _ := client.PutMapping().Index("user").BodyString(bd).Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{ "acknowledged": true, "shards_acknowledged": false }

創建文檔時自動創建索引

rst, _ := client.Index().Index("user").BodyJson(&User{Name: "noname1"}).Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{
    "_index": "user",
    "_type": "_doc",
    "_id": "Y70mWHQBIsMSghaJdERa",
    "_version": 1,
    "result": "created",
    "_shards": { "total": 2, "successful": 1, "failed": 0 },
    "_primary_term": 1
}

修改副本數量

bd := `{
  "index" : {
    "number_of_replicas" : 3
  }
}`
rst, _ := client.IndexPutSettings("user").BodyString(bd).Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{ "acknowledged": true, "shards_acknowledged": false }

修改分片數量

bd := `{
  "index" : {
    "number_of_shards" : 2
  }
}`
rst, err := client.IndexPutSettings("user").BodyString(bd).Do(ctx)
if err != nil {
    fmt.Println(err.Error())
    return
}
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

elastic: Error 400 (Bad Request): Can't update non dynamic settings [[index.number_of_shards]] for open indices [[user/F4eP0Sq-S9a9pBJhN_eYVQ]] [type=illegal_argument_exception]
  • 說明:分片數量,必須在索引創建時指定,創建后無法修改。嘗試修改時會報錯

刪除索引

rst, _ := client.DeleteIndex("user").Do(ctx)
buf, _ := json.Marshal(rst)
fmt.Println(string(buf))
  • 返回

{ "acknowledged": true }

到此,相信大家對“elasticsearch索引怎么創建”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

辉县市| 翁牛特旗| 佛山市| 义乌市| 福州市| 海阳市| 淮安市| 江城| 江陵县| 淮北市| 阜康市| 乐陵市| 涞源县| 招远市| 邵东县| 奎屯市| 游戏| 宁阳县| 那坡县| 鹿泉市| 额济纳旗| 涞水县| 和政县| 奇台县| 行唐县| 饶河县| 长丰县| 柏乡县| 青神县| 翁源县| 安平县| 罗田县| 常州市| 筠连县| 兰西县| 古蔺县| 孙吴县| 汕尾市| 冀州市| 兴宁市| 和静县|