{"id":87947,"date":"2025-04-12T22:06:59","date_gmt":"2025-04-12T15:06:59","guid":{"rendered":"https:\/\/itviecblog.uptech.vn\/?p=85956"},"modified":"2025-06-17T14:47:19","modified_gmt":"2025-06-17T07:47:19","slug":"huong-dan-delete-index-elasticsearch","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/","title":{"rendered":"Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Huong_dan_delete_index_Elasticsearch_Su_dung_REST_API\" >H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: S\u1eed d\u1ee5ng REST API<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Huong_dan_delete_index_Elasticsearch_Su_dung_Kibana_Dev_Tools\" >H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: S\u1eed d\u1ee5ng Kibana Dev Tools<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Huong_dan_delete_index_Elasticsearch_Su_dung_Curator_Tuy_chon\" >H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: S\u1eed d\u1ee5ng Curator (T\u00f9y ch\u1ecdn)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Huong_dan_delete_index_Elasticsearch_Xoa_thu_cong_CLI_hoac_Script\" >H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: X\u00f3a th\u1ee7 c\u00f4ng (CLI ho\u1eb7c Script)\u00a0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Nhung_dieu_can_luu_y_khi_xoa_Index_trong_Elasticsearch\" >Nh\u1eefng \u0111i\u1ec1u c\u1ea7n l\u01b0u \u00fd khi x\u00f3a Index trong Elasticsearch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Huong_dan_quan_ly_Index_trong_Elasticsearch_hieu_qua\" >H\u01b0\u1edbng d\u1eabn qu\u1ea3n l\u00fd Index trong Elasticsearch hi\u1ec7u qu\u1ea3<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Cau_hoi_thuong_gap_ve_delete_index_Elasticsearch\" >C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 delete index Elasticsearch<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#Tong_ket_delete_index_Elasticsearch\" >T\u1ed5ng k\u1ebft delete index Elasticsearch<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>Trong qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng Elasticsearch, \u0111\u00f4i khi b\u1ea1n c\u1ea7n x\u00f3a c\u00e1c Index kh\u00f4ng c\u00f2n c\u1ea7n thi\u1ebft \u0111\u1ec3 gi\u1ea3i ph\u00f3ng dung l\u01b0\u1ee3ng l\u01b0u tr\u1eef ho\u1eb7c \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c qu\u1ea3n l\u00fd d\u1eef li\u1ec7u. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n t\u1eebng b\u01b0\u1edbc c\u00e1ch delete Index Elasticsearch, t\u1eeb nh\u1eefng thao t\u00e1c c\u01a1 b\u1ea3n \u0111\u1ebfn c\u00e1c ph\u01b0\u01a1ng ph\u00e1p n\u00e2ng cao, gi\u00fap b\u1ea1n th\u1ef1c hi\u1ec7n vi\u1ec7c x\u00f3a index m\u1ed9t c\u00e1ch hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n.<\/strong><\/em><\/p>\n<p><span style=\"font-weight: 400;\">B\u1ea1n s\u1ebd t\u00ecm th\u1ea5y trong b\u00e0i vi\u1ebft n\u00e0y:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1ch x\u00f3a Index trong Elasticsearch<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Nh\u1eefng \u0111i\u1ec1u c\u1ea7n l\u01b0u \u00fd khi x\u00f3a Index trong Elasticsearch<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u01b0\u1edbng d\u1eabn qu\u1ea3n l\u00fd Index hi\u1ec7u qu\u1ea3<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p khi x\u00f3a Index trong Elasticsearch<\/span><\/li>\n<\/ul>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"\/blog\/elasticsearch-la-gi\/\" target=\"_blank\" rel=\"noopener\"><strong>T\u1eeb A \u0111\u1ebfn Z v\u1ec1 Elasticsearch: \u201cV\u0169 kh\u00ed\u201d b\u00ed m\u1eadt cho c\u00e1c \u1ee9ng d\u1ee5ng d\u1eef li\u1ec7u l\u1edbn<\/strong><\/a><\/em><\/p><\/blockquote>\n<h2><span class=\"ez-toc-section\" id=\"Huong_dan_delete_index_Elasticsearch_Su_dung_REST_API\"><\/span><b>H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: <\/b><b>S\u1eed d\u1ee5ng REST API<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">X\u00f3a m\u1ed9t Index s\u1ebd x\u00f3a c\u00e1c t\u00e0i li\u1ec7u, ph\u00e2n \u0111o\u1ea1n v\u00e0 si\u00eau d\u1eef li\u1ec7u c\u1ee7a Index \u0111\u00f3. N\u00f3 kh\u00f4ng x\u00f3a c\u00e1c th\u00e0nh ph\u1ea7n Kibana li\u00ean quan, ch\u1eb3ng h\u1ea1n nh\u01b0 ch\u1ebf \u0111\u1ed9 xem d\u1eef li\u1ec7u, h\u00ecnh \u1ea3nh tr\u1ef1c quan ho\u1eb7c b\u1ea3ng \u0111i\u1ec1u khi\u1ec3n. B\u1ea1n kh\u00f4ng th\u1ec3 x\u00f3a write index c\u1ee7a lu\u1ed3ng d\u1eef li\u1ec7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 x\u00f3a index, b\u1ea1n ph\u1ea3i di chuy\u1ec3n lu\u1ed3ng d\u1eef li\u1ec7u \u0111\u1ec3 t\u1ea1o write index m\u1edbi. Sau \u0111\u00f3, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng API \u0111\u1ec3 x\u00f3a write index tr\u01b0\u1edbc \u0111\u00f3. N\u1ebfu t\u00ednh n\u0103ng b\u1ea3o m\u1eadt Elasticsearch \u0111\u01b0\u1ee3c b\u1eadt, b\u1ea1n ph\u1ea3i c\u00f3 quy\u1ec1n <\/span><span style=\"font-weight: 400;\">delete_index<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">manage <\/span><span style=\"font-weight: 400;\">cho index m\u1ee5c ti\u00eau. L\u01b0u \u00fd r\u1eb1ng vi\u1ec7c x\u00f3a index l\u00e0 kh\u00f4ng th\u1ec3 ho\u00e0n t\u00e1c, n\u00ean c\u00e2n nh\u1eafc sao l\u01b0u d\u1eef li\u1ec7u tr\u01b0\u1edbc khi th\u1ef1c hi\u1ec7n.<\/span><\/p>\n<p><b>C\u00e1c tham s\u1ed1 quan tr\u1ecdng:<\/b><\/p>\n<h3><b>Tham s\u1ed1 \u0111\u01b0\u1eddng d\u1eabn: <\/b><b>&lt;index&gt;<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Danh s\u00e1ch c\u00e1c index \u0111\u01b0\u1ee3c ph\u00e2n t\u00e1ch b\u1eb1ng d\u1ea5u ph\u1ea9y \u0111\u1ec3 x\u00f3a. B\u1ea1n kh\u00f4ng th\u1ec3 ch\u1ec9 \u0111\u1ecbnh index aliases. Theo m\u1eb7c \u0111\u1ecbnh, tham s\u1ed1 n\u00e0y kh\u00f4ng h\u1ed7 tr\u1ee3 k\u00fd t\u1ef1 \u0111\u1ea1i di\u1ec7n ( *) ho\u1eb7c <\/span><span style=\"font-weight: 400;\">_all<\/span><span style=\"font-weight: 400;\">. \u0110\u1ec3 s\u1eed d\u1ee5ng k\u00fd t\u1ef1 \u0111\u1ea1i di\u1ec7n ho\u1eb7c <\/span><span style=\"font-weight: 400;\">_all<\/span><span style=\"font-weight: 400;\">, h\u00e3y \u0111\u1eb7t <\/span><span style=\"font-weight: 400;\">action.destructive_requires_name<\/span><span style=\"font-weight: 400;\"> c\u00e0i \u0111\u1eb7t cluster th\u00e0nh <\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\"> trong t\u1ec7p c\u1ea5u h\u00ecnh Elasticsearch ho\u1eb7c qua API:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">PUT _cluster\/settings<\/span>\n<span style=\"font-weight: 400;\">{<\/span>\n<span style=\"font-weight: 400;\"> \u00a0\"persistent\": {<\/span>\n<span style=\"font-weight: 400;\"> \u00a0\u00a0\u00a0\"action.destructive_requires_name\": false<\/span>\n<span style=\"font-weight: 400;\"> \u00a0}<\/span>\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h3><b>Tham s\u1ed1 truy v\u1ea5n<\/b><\/h3>\n<h4><b>allow_no_indices<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">N\u1ebfu <\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">, request s\u1ebd b\u00e1o l\u1ed7i n\u1ebfu c\u00f3 b\u1ea5t k\u1ef3 bi\u1ec3u th\u1ee9c wildcard n\u00e0o \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng (v\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">foo*<\/span><span style=\"font-weight: 400;\">), index aliases ho\u1eb7c gi\u00e1 tr\u1ecb <\/span><span style=\"font-weight: 400;\">_all <\/span><span style=\"font-weight: 400;\">n\u00e0o ch\u1ec9 nh\u1eafm m\u1ee5c ti\u00eau \u0111\u1ebfn c\u00e1c index b\u1ecb thi\u1ebfu ho\u1eb7c \u0111\u00e3 \u0111\u00f3ng. H\u00e0nh vi n\u00e0y \u00e1p d\u1ee5ng ngay c\u1ea3 khi y\u00eau c\u1ea7u nh\u1eafm m\u1ee5c ti\u00eau \u0111\u1ebfn c\u00e1c open index kh\u00e1c. V\u00ed d\u1ee5: y\u00eau c\u1ea7u nh\u1eafm m\u1ee5c ti\u00eau <\/span><span style=\"font-weight: 400;\">foo*,bar*<\/span><span style=\"font-weight: 400;\"> tr\u1ea3 v\u1ec1 l\u1ed7i n\u1ebfu index b\u1eaft \u0111\u1ea7u b\u1eb1ng <\/span><span style=\"font-weight: 400;\">foo <\/span><span style=\"font-weight: 400;\">nh\u01b0ng kh\u00f4ng c\u00f3 index n\u00e0o b\u1eaft \u0111\u1ea7u b\u1eb1ng <\/span><span style=\"font-weight: 400;\">bar<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">M\u1eb7c \u0111\u1ecbnh l\u00e0 <\/span><span style=\"font-weight: 400;\">true<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h4><b>expand_wildcards<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Tham s\u1ed1 x\u00e1c \u0111\u1ecbnh lo\u1ea1i index m\u00e0 c\u00e1c bi\u1ec3u th\u1ee9c wildcard c\u00f3 th\u1ec3 \u00e1p d\u1ee5ng. Trong tr\u01b0\u1eddng h\u1ee3p y\u00eau c\u1ea7u c\u00f3 th\u1ec3 t\u00e1c \u0111\u1ed9ng \u0111\u1ebfn lu\u1ed3ng d\u1eef li\u1ec7u , tham s\u1ed1 n\u00e0y quy \u0111\u1ecbnh vi\u1ec7c c\u00e1c bi\u1ec3u th\u1ee9c wildcard c\u00f3 bao g\u1ed3m lu\u1ed3ng d\u1eef li\u1ec7u \u1ea9n hay kh\u00f4ng. H\u1ed7 tr\u1ee3 nh\u1eadp li\u1ec7u nhi\u1ec1u gi\u00e1 tr\u1ecb ph\u00e2n t\u00e1ch b\u1eb1ng d\u1ea5u ph\u1ea9y, v\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">open,hidden.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u00e1c gi\u00e1 tr\u1ecb h\u1ee3p l\u1ec7 bao g\u1ed3m:<\/span><\/p>\n<ul>\n<li><b>all: <\/b>Ph\u00f9 h\u1ee3p v\u1edbi b\u1ea5t k\u1ef3 lu\u1ed3ng d\u1eef li\u1ec7u ho\u1eb7c index n\u00e0o, bao g\u1ed3m c\u1ea3 d\u1eef li\u1ec7u \u1ea9n .<\/li>\n<li><b>open: <\/b>Ph\u00f9 h\u1ee3p v\u1edbi c\u00e1c open index, kh\u00f4ng \u1ea9n. C\u0169ng ph\u00f9 h\u1ee3p v\u1edbi b\u1ea5t k\u1ef3 lu\u1ed3ng d\u1eef li\u1ec7u kh\u00f4ng \u1ea9n n\u00e0o.<\/li>\n<li><b>closed: <\/b>Ph\u00f9 h\u1ee3p v\u1edbi c\u00e1c index \u0111\u00e3 \u0111\u00f3ng, kh\u00f4ng \u1ea9n. C\u0169ng ph\u00f9 h\u1ee3p v\u1edbi b\u1ea5t k\u1ef3 lu\u1ed3ng d\u1eef li\u1ec7u n\u00e0o kh\u00f4ng \u1ea9n. Kh\u00f4ng th\u1ec3 \u0111\u00f3ng lu\u1ed3ng d\u1eef li\u1ec7u.<\/li>\n<li><b>hidden: <\/b>Ph\u00f9 h\u1ee3p v\u1edbi lu\u1ed3ng d\u1eef li\u1ec7u \u1ea9n v\u00e0 index \u1ea9n. Ph\u1ea3i k\u1ebft h\u1ee3p v\u1edbi <span>open, closed<\/span><span>, ho\u1eb7c c\u1ea3 hai.<\/span><\/li>\n<li><b>none: <\/b>Kh\u00f4ng ch\u1ea5p nh\u1eadn m\u1eabu wildcard.<\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">M\u1eb7c \u0111\u1ecbnh l\u00e0 <\/span><b>open,closed<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h4><b>ignore_unavailable<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">N\u1ebfu <\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">, y\u00eau c\u1ea7u s\u1ebd tr\u1ea3 v\u1ec1 l\u1ed7i trong tr\u01b0\u1eddng h\u1ee3p n\u00f3 nh\u1eafm m\u1ee5c ti\u00eau v\u00e0o index b\u1ecb thi\u1ebfu ho\u1eb7c \u0111\u00e3 \u0111\u00f3ng. M\u1eb7c \u0111\u1ecbnh l\u00e0 <\/span><span style=\"font-weight: 400;\">false<\/span><span style=\"font-weight: 400;\">.<\/span><\/p>\n<h4><b>master_timeout<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Kho\u1ea3ng th\u1eddi gian ch\u1edd cho master node. N\u1ebfu master node kh\u00f4ng kh\u1ea3 d\u1ee5ng tr\u01b0\u1edbc khi h\u1ebft th\u1eddi gian ch\u1edd, y\u00eau c\u1ea7u s\u1ebd kh\u00f4ng th\u00e0nh c\u00f4ng v\u00e0 tr\u1ea3 v\u1ec1 l\u1ed7i, m\u1eb7c \u0111\u1ecbnh l\u00e0 <\/span><span style=\"font-weight: 400;\">30s<\/span><span style=\"font-weight: 400;\">. C\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111\u1eb7t th\u00e0nh <\/span><span style=\"font-weight: 400;\">-1<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 ch\u1ec9 ra r\u1eb1ng y\u00eau c\u1ea7u kh\u00f4ng bao gi\u1edd h\u1ebft th\u1eddi gian ch\u1edd.<\/span><\/p>\n<h4><b>timeout<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Kho\u1ea3ng th\u1eddi gian ch\u1edd ph\u1ea3n h\u1ed3i t\u1eeb t\u1ea5t c\u1ea3 c\u00e1c node c\u00f3 li\u00ean quan trong cluster sau khi c\u1eadp nh\u1eadt cluster metadata. N\u1ebfu kh\u00f4ng nh\u1eadn \u0111\u01b0\u1ee3c ph\u1ea3n h\u1ed3i tr\u01b0\u1edbc khi h\u1ebft th\u1eddi gian ch\u1edd, b\u1ea3n c\u1eadp nh\u1eadt cluster metadata v\u1eabn \u00e1p d\u1ee5ng nh\u01b0ng ph\u1ea3n h\u1ed3i s\u1ebd ch\u1ec9 ra n\u00f3 ch\u01b0a \u0111\u01b0\u1ee3c x\u00e1c nh\u1eadn ho\u00e0n to\u00e0n. M\u1eb7c \u0111\u1ecbnh l\u00e0 <\/span><span style=\"font-weight: 400;\">30s<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c c\u0169ng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111\u1eb7t th\u00e0nh <\/span><span style=\"font-weight: 400;\">-1 <\/span><span style=\"font-weight: 400;\">\u0111\u1ec3 ch\u1ec9 ra y\u00eau c\u1ea7u kh\u00f4ng bao gi\u1edd h\u1ebft th\u1eddi gian ch\u1edd.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Huong_dan_delete_index_Elasticsearch_Su_dung_Kibana_Dev_Tools\"><\/span><b>H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: S\u1eed d\u1ee5ng Kibana Dev Tools<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u1edf Kibana: \u0110i t\u1edbi ph\u1ea7n Dev Tools trong Kibana.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Th\u1ef1c hi\u1ec7n l\u1ec7nh DELETE: Ch\u1ea1y l\u1ec7nh DELETE cho c\u00e1c index b\u1ea1n mu\u1ed1n x\u00f3a:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">DELETE \/index_name<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 x\u00f3a nhi\u1ec1u index\u00a0 kh\u1edbp v\u1edbi m\u1ed9t m\u1eabu:\u00a0<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">DELETE \/logs-2023-01-*<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">X\u00e1c nh\u1eadn x\u00f3a: Ki\u1ec3m tra tr\u1ea1ng th\u00e1i \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o index \u0111\u00e3 b\u1ecb x\u00f3a (<\/span><span style=\"font-weight: 400;\">l\u1ec7nh n\u00e0y li\u1ec7t k\u00ea t\u1ea5t c\u1ea3 index hi\u1ec7n c\u00f3 \u0111\u1ec3 x\u00e1c nh\u1eadn index \u0111\u00e3 \u0111\u01b0\u1ee3c x\u00f3a)<\/span><span style=\"font-weight: 400;\">:\u00a0<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">GET \/_cat\/indices?v<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Huong_dan_delete_index_Elasticsearch_Su_dung_Curator_Tuy_chon\"><\/span><b>H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: S\u1eed d\u1ee5ng Curator (T\u00f9y ch\u1ecdn)<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Elasticsearch Curator l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 d\u00f2ng l\u1ec7nh \u0111\u1ec3 qu\u1ea3n l\u00fd c\u00e1c index v\u00e0 \u1ea3nh ch\u1ee5p nhanh. C\u00f4ng c\u1ee5 n\u00e0y h\u1eefu \u00edch \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5 nh\u01b0 x\u00f3a c\u00e1c index c\u0169.<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e0i \u0111\u1eb7t Curator: Th\u1ef1c hi\u1ec7n theo h\u01b0\u1edbng d\u1eabn c\u00e0i \u0111\u1eb7t t\u1eeb <\/span><a href=\"https:\/\/www.elastic.co\/guide\/en\/elasticsearch\/client\/curator\/current\/quickstart.html\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">t\u00e0i li\u1ec7u Elasticsearch Curator<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ec7p curator.yml ch\u1ee9a th\u00f4ng tin k\u1ebft n\u1ed1i:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">client:<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0hosts: [\"localhost\"]<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0port: 9200<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ea1o t\u1ec7p c\u1ea5u h\u00ecnh Curator: X\u00e1c \u0111\u1ecbnh c\u00e1c h\u00e0nh \u0111\u1ed9ng Curator c\u1ee7a b\u1ea1n trong t\u1ec7p YAML (v\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">delete_old_indices.yml<\/span><span style=\"font-weight: 400;\">).<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">actions:<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a01:<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0action: delete_indices<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0description: \"Delete indices older than 30 days\"<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0options:<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0ignore_empty_list: True<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0allow_ilm_indices: False<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0filters:<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0- filtertype: age<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0source: creation_date<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0direction: older<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0unit: days<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0value: 30<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ch\u1ea1y Curator: Th\u1ef1c thi Curator b\u1eb1ng t\u1ec7p c\u1ea5u h\u00ecnh:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">curator --config \/path\/to\/curator.yml \/path\/to\/delete_old_indices.yml<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Huong_dan_delete_index_Elasticsearch_Xoa_thu_cong_CLI_hoac_Script\"><\/span><b>H\u01b0\u1edbng d\u1eabn delete index Elasticsearch: X\u00f3a th\u1ee7 c\u00f4ng (CLI ho\u1eb7c Script)\u00a0<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 vi\u1ebft c\u00e1c t\u1eadp l\u1ec7nh b\u1eb1ng ng\u00f4n ng\u1eef nh\u01b0 Python b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng th\u01b0 vi\u1ec7n <\/span><span style=\"font-weight: 400;\">elasticsearch-py<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 x\u00f3a c\u00e1c index c\u0169 theo ch\u01b0\u01a1ng tr\u00ecnh. V\u00ed d\u1ee5 v\u1edbi Python:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">from elasticsearch import Elasticsearch<\/span>\n\n<span style=\"font-weight: 400;\">es = Elasticsearch([\"&lt;http:\/\/localhost:9200&gt;\"])<\/span>\n\n<span style=\"font-weight: 400;\"># Define index pattern<\/span>\n\n<span style=\"font-weight: 400;\">index_pattern = \"logs-2023-01-*\"<\/span>\n\n<span style=\"font-weight: 400;\"># List indices matching pattern<\/span>\n\n<span style=\"font-weight: 400;\">indices = es.cat.indices(index=index_pattern, format=\"json\")<\/span>\n\n<span style=\"font-weight: 400;\"># Delete each index<\/span>\n\n<span style=\"font-weight: 400;\">for index in indices:<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0index_name = index['index']<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0es.indices.delete(index=index_name)<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0print(f\"Deleted index: {index_name}\")<\/span><\/pre>\n<p>L\u01b0u \u00fd quan tr\u1ecdng:<\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Quy\u1ec1n truy c\u1eadp<\/b><span style=\"font-weight: 400;\">: \u0110\u1ea3m b\u1ea3o t\u00e0i kho\u1ea3n ho\u1eb7c script c\u00f3 quy\u1ec1n x\u00f3a index <\/span><span style=\"font-weight: 400;\">(indices:admin\/delete).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Sao l\u01b0u<\/b><span style=\"font-weight: 400;\">: Tr\u01b0\u1edbc khi x\u00f3a, c\u00e2n nh\u1eafc t\u1ea1o snapshot \u0111\u1ec3 tr\u00e1nh m\u1ea5t d\u1eef li\u1ec7u quan tr\u1ecdng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ki\u1ec3m tra c\u1ea5u h\u00ecnh<\/b><span style=\"font-weight: 400;\">: N\u1ebfu g\u1eb7p l\u1ed7i v\u1edbi wildcard ho\u1eb7c _all, ki\u1ec3m tra c\u00e0i \u0111\u1eb7t <\/span><span style=\"font-weight: 400;\">action.destructive_requires_name.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Nhung_dieu_can_luu_y_khi_xoa_Index_trong_Elasticsearch\"><\/span><b>Nh\u1eefng \u0111i\u1ec1u c\u1ea7n l\u01b0u \u00fd khi x\u00f3a Index trong Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>&nbsp;<\/p>\n<p><b>Sao l\u01b0u d\u1eef li\u1ec7u quan tr\u1ecdng:<\/b><span style=\"font-weight: 400;\"> Tr\u01b0\u1edbc khi x\u00f3a index, h\u00e3y \u0111\u1ea3m b\u1ea3o r\u1eb1ng b\u1ea1n \u0111\u00e3 sao l\u01b0u m\u1ecdi d\u1eef li\u1ec7u quan tr\u1ecdng. Sau khi x\u00f3a index, d\u1eef li\u1ec7u kh\u00f4ng th\u1ec3 kh\u00f4i ph\u1ee5c \u0111\u01b0\u1ee3c.<\/span><\/p>\n<p><b>Theo d\u00f5i t\u00ecnh tr\u1ea1ng cluster:<\/b><span style=\"font-weight: 400;\"> Vi\u1ec7c x\u00f3a index c\u00f3 th\u1ec3 khi\u1ebfn t\u1ea3i cluster t\u1ea1m th\u1eddi t\u0103ng l\u00ean v\u00ec c\u00e1c shard \u0111\u01b0\u1ee3c c\u00e2n b\u1eb1ng l\u1ea1i tr\u00ean c\u00e1c node. Theo d\u00f5i t\u00ecnh tr\u1ea1ng cluster trong qu\u00e1 tr\u00ecnh x\u00f3a \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o cluster v\u1eabn \u1ed5n \u0111\u1ecbnh.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/_cluster\/health<\/span><\/pre>\n<p><b>S\u1eed d\u1ee5ng alias:<\/b><span style=\"font-weight: 400;\"> N\u1ebfu b\u1ea1n th\u01b0\u1eddng xuy\u00ean x\u00f3a v\u00e0 t\u1ea1o l\u1ea1i c\u00e1c index c\u00f3 t\u00ean t\u01b0\u01a1ng t\u1ef1, h\u00e3y c\u00e2n nh\u1eafc s\u1eed d\u1ee5ng index alias &#8211; m\u1ed9t ki\u1ec3u b\u00ed danh c\u1ee7a index. Alias cho ph\u00e9p b\u1ea1n chuy\u1ec3n \u0111\u1ed5i gi\u1eefa c\u00e1c index kh\u00e1c nhau m\u00e0 kh\u00f4ng c\u1ea7n thay \u0111\u1ed5i m\u00e3 \u1ee9ng d\u1ee5ng.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">POST \/_aliases<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"actions\": [<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0{ \"add\": { \"index\": \"new_index\", \"alias\": \"my_alias\" } },<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0{ \"remove\": { \"index\": \"old_index\", \"alias\": \"my_alias\" } }<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0]<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><b>T\u1ed1i \u01b0u h\u00f3a qu\u1ea3n l\u00fd v\u00f2ng \u0111\u1eddi index (ILM):<\/b><span style=\"font-weight: 400;\"> Elasticsearch cung c\u1ea5p c\u00e1c ch\u00ednh s\u00e1ch ILM \u0111\u1ec3 t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c t\u00e1c v\u1ee5 qu\u1ea3n l\u00fd index, ch\u1eb3ng h\u1ea1n nh\u01b0 chuy\u1ec3n \u0111\u1ed5i, thu nh\u1ecf v\u00e0 x\u00f3a. Th\u00f4ng qua ILM, b\u1ea1n c\u00f3 th\u1ec3 \u0111\u1ea3m b\u1ea3o c\u00e1c index s\u1ebd b\u1ecb x\u00f3a khi kh\u00f4ng c\u00f2n c\u1ea7n thi\u1ebft, gi\u1ea3m s\u1ef1 can thi\u1ec7p th\u1ee7 c\u00f4ng.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">PUT _ilm\/policy\/my_policy<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"policy\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"phases\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"delete\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"min_age\": \"30d\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"actions\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"delete\": {}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Ngo\u00e0i ra, tr\u01b0\u1edbc khi x\u00f3a Index trong Elasticsearch, b\u1ea1n c\u0169ng l\u01b0u \u00fd m\u1ed9t s\u1ed1 r\u1ee7i ro ti\u1ec1m \u1ea9n nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Hi\u1ec7u su\u1ea5t cluster: Vi\u1ec7c x\u00f3a m\u1ed9t index l\u1edbn ho\u1eb7c nhi\u1ec1u index c\u00f9ng l\u00fac c\u00f3 th\u1ec3 khi\u1ebfn t\u0103ng v\u1ecdt t\u1ea1m th\u1eddi v\u1ec1 t\u1ea3i x\u1eed l\u00fd c\u1ee7a cluster, \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn hi\u1ec7u su\u1ea5t. \u0110\u1ec3 gi\u1ea3m thi\u1ec3u t\u00e1c \u0111\u1ed9ng, h\u00e3y c\u00e2n nh\u1eafc x\u00f3a index trong th\u1eddi gian cluster ho\u1ea1t \u0111\u1ed9ng th\u1ea5p.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u1ea5t d\u1eef li\u1ec7u: X\u00f3a index s\u1ebd x\u00f3a v\u0129nh vi\u1ec5n d\u1eef li\u1ec7u trong \u0111\u00f3. \u0110\u1ea3m b\u1ea3o r\u1eb1ng b\u1ea1n \u0111\u00e3 sao l\u01b0u m\u1ecdi d\u1eef li\u1ec7u quan tr\u1ecdng tr\u01b0\u1edbc khi ti\u1ebfn h\u00e0nh x\u00f3a.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">B\u1ea3o m\u1eadt: \u0110\u1ea3m b\u1ea3o r\u1eb1ng ch\u1ec9 nh\u1eefng ng\u01b0\u1eddi d\u00f9ng \u0111\u01b0\u1ee3c \u1ee7y quy\u1ec1n m\u1edbi c\u00f3 kh\u1ea3 n\u0103ng x\u00f3a index. C\u1ea5u h\u00ecnh c\u00e1c t\u00ednh n\u0103ng b\u1ea3o m\u1eadt c\u1ee7a Elasticsearch, ch\u1eb3ng h\u1ea1n nh\u01b0 ki\u1ec3m so\u00e1t truy c\u1eadp d\u1ef1a tr\u00ean vai tr\u00f2, \u0111\u1ec3 h\u1ea1n ch\u1ebf quy\u1ec1n truy c\u1eadp v\u00e0o c\u00e1c ho\u1ea1t \u0111\u1ed9ng nh\u1ea1y c\u1ea3m.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Huong_dan_quan_ly_Index_trong_Elasticsearch_hieu_qua\"><\/span><b>H\u01b0\u1edbng d\u1eabn qu\u1ea3n l\u00fd Index trong Elasticsearch hi\u1ec7u qu\u1ea3<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Vi\u1ec7c qu\u1ea3n l\u00fd index t\u1ed1t s\u1ebd gi\u00fap qu\u00e1 tr\u00ecnh x\u00f3a index di\u1ec5n ra hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n h\u01a1n, \u0111\u1ed3ng th\u1eddi gi\u1ea3m thi\u1ec3u c\u00e1c t\u00e1c \u0111\u1ed9ng ti\u00eau c\u1ef1c c\u00f3 th\u1ec3 x\u1ea3y ra, c\u1ee5 th\u1ec3 nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>D\u1ec5 d\u00e0ng x\u00e1c \u0111\u1ecbnh index c\u1ea7n x\u00f3a:<\/b><span style=\"font-weight: 400;\"> Khi c\u00f3 m\u1ed9t h\u1ec7 th\u1ed1ng qu\u1ea3n l\u00fd index t\u1ed1t, b\u1ea1n s\u1ebd c\u00f3 th\u00f4ng tin chi ti\u1ebft v\u1ec1 t\u1eebng index, bao g\u1ed3m: B\u1ea3ng v\u00e0 c\u1ed9t m\u00e0 index \u0111\u01b0\u1ee3c t\u1ea1o tr\u00ean \u0111\u00f3, lo\u1ea1i index, m\u1ee5c \u0111\u00edch s\u1eed d\u1ee5ng c\u1ee7a index, t\u1ea7n su\u1ea5t s\u1eed d\u1ee5ng index, k\u00edch th\u01b0\u1edbc c\u1ee7a index, th\u1eddi \u0111i\u1ec3m index \u0111\u01b0\u1ee3c t\u1ea1o ho\u1eb7c l\u1ea7n cu\u1ed1i c\u00f9ng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>\u0110\u00e1nh gi\u00e1 t\u00e1c \u0111\u1ed9ng tr\u01b0\u1edbc khi x\u00f3a:<\/b><span style=\"font-weight: 400;\"> Qu\u1ea3n l\u00fd index t\u1ed1t th\u01b0\u1eddng bao g\u1ed3m theo d\u00f5i hi\u1ec7u su\u1ea5t truy v\u1ea5n v\u00e0 x\u00e1c \u0111\u1ecbnh nh\u1eefng index n\u00e0o kh\u00f4ng c\u00f2n mang l\u1ea1i l\u1ee3i \u00edch ho\u1eb7c th\u1eadm ch\u00ed g\u00e2y ra chi ph\u00ed b\u1ea3o tr\u00ec kh\u00f4ng c\u1ea7n thi\u1ebft. Tr\u01b0\u1edbc khi x\u00f3a m\u1ed9t index, b\u1ea1n c\u00f3 th\u1ec3 \u0111\u00e1nh gi\u00e1 t\u00e1c \u0111\u1ed9ng l\u00ean c\u00e1c truy v\u1ea5n hi\u1ec7n t\u1ea1i. V\u00ed d\u1ee5 n\u1ebfu m\u1ed9t index v\u1eabn \u0111ang \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng th\u01b0\u1eddng xuy\u00ean b\u1edfi c\u00e1c truy v\u1ea5n quan tr\u1ecdng, vi\u1ec7c x\u00f3a n\u00f3 s\u1ebd l\u00e0m ch\u1eadm c\u00e1c truy v\u1ea5n n\u00e0y.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>L\u1eadp k\u1ebf ho\u1ea1ch x\u00f3a index hi\u1ec7u qu\u1ea3:<\/b><span style=\"font-weight: 400;\"> Qu\u1ea3n l\u00fd index gi\u00fap x\u00e1c \u0111\u1ecbnh th\u1eddi \u0111i\u1ec3m th\u00edch h\u1ee3p \u0111\u1ec3 x\u00f3a index. V\u00ed d\u1ee5, b\u1ea1n quy\u1ebft \u0111\u1ecbnh x\u00f3a c\u00e1c index kh\u00f4ng c\u00f2n c\u1ea7n thi\u1ebft sau \u0111\u1ee3t b\u00e1o c\u00e1o \u0111\u1ecbnh k\u1ef3 ho\u1eb7c khi m\u1ed9t t\u00ednh n\u0103ng kh\u00f4ng c\u00f2n \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Gi\u1ea3m thi\u1ec3u r\u1ee7i ro x\u00f3a nh\u1ea7m index quan tr\u1ecdng:<\/b><span style=\"font-weight: 400;\"> \u0110i\u1ec1u n\u00e0y nh\u1edd v\u00e0o vi\u1ec7c b\u1ea1n \u0111\u00e3 c\u00f3 c\u00e1i nh\u00ecn t\u1ed5ng quan v\u00e0 ghi ch\u00e9p \u0111\u1ea7y \u0111\u1ee7 v\u1ec1 c\u00e1c index.<\/span><\/li>\n<\/ul>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"\/blog\/huong-dan-elasticsearch-tutorial\/\" target=\"_blank\" rel=\"noopener\"><strong>Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n<\/strong><\/a><\/em><\/p><\/blockquote>\n<p><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 nh\u1eefng \u0111i\u1ec1u c\u1ea7n l\u01b0u \u00fd \u0111\u1ec3 qu\u1ea3n l\u00fd index hi\u1ec7u qu\u1ea3:<\/span><\/p>\n<h3><b>1. T\u1ed1i \u01b0u h\u00f3a d\u1eef li\u1ec7u chu\u1ed7i th\u1eddi gian<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Vi\u1ec7c s\u1eed d\u1ee5ng Elasticsearch \u0111\u1ec3 l\u01b0u tr\u1eef v\u00e0 ph\u00e2n t\u00edch d\u1eef li\u1ec7u chu\u1ed7i th\u1eddi gian, ch\u1eb3ng h\u1ea1n nh\u01b0 nh\u1eadt k\u00fd \u1ee9ng d\u1ee5ng ho\u1eb7c s\u1ef1 ki\u1ec7n IoT, \u0111\u00f2i h\u1ecfi vi\u1ec7c qu\u1ea3n l\u00fd kh\u1ed1i l\u01b0\u1ee3ng d\u1eef li\u1ec7u kh\u1ed5ng l\u1ed3 trong th\u1eddi gian d\u00e0i.<\/span><\/p>\n<h4><b>Elasticsearch Rollover<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">D\u1eef li\u1ec7u chu\u1ed7i th\u1eddi gian th\u01b0\u1eddng \u0111\u01b0\u1ee3c ph\u00e2n b\u1ed5 tr\u00ean nhi\u1ec1u index. M\u1ed9t c\u00e1ch \u0111\u01a1n gi\u1ea3n \u0111\u1ec3 th\u1ef1c hi\u1ec7n \u0111i\u1ec1u n\u00e0y l\u00e0 t\u1ea1o m\u1ed9t index ri\u00eang bi\u1ec7t cho c\u00e1c kho\u1ea3ng th\u1eddi gian t\u00f9y \u00fd, v\u00ed d\u1ee5: 1 index cho m\u1ed7i ng\u00e0y. M\u1ed9t ph\u01b0\u01a1ng ph\u00e1p kh\u00e1c l\u00e0 s\u1eed d\u1ee5ng Rollover API gi\u00fap b\u1ea1n t\u1ef1 \u0111\u1ed9ng t\u1ea1o m\u1ed9t index m\u1edbi khi index ch\u00ednh qu\u00e1 c\u0169, qu\u00e1 l\u1edbn ho\u1eb7c c\u00f3 qu\u00e1 nhi\u1ec1u t\u00e0i li\u1ec7u.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">POST \/my_alias\/_rollover<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"conditions\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"max_age\": \"7d\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"max_docs\": 1000000,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"max_size\": \"5gb\"<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h4><b>Elasticsearch Shrink<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Khi c\u00e1c index c\u0169 h\u01a1n v\u00e0 d\u1eef li\u1ec7u c\u1ee7a ch\u00fang tr\u1edf n\u00ean \u00edt li\u00ean quan h\u01a1n, c\u1ea7n th\u1ef1c hi\u1ec7n 1 s\u1ed1 vi\u1ec7c \u0111\u1ec3 index s\u1eed d\u1ee5ng \u00edt t\u00e0i nguy\u00ean h\u01a1n, t\u1eeb \u0111\u00f3 Elasticsearch c\u00f3 kh\u1ea3 n\u0103ng cung c\u1ea5p nhi\u1ec1u t\u00e0i nguy\u00ean cho c\u00e1c index ho\u1ea1t \u0111\u1ed9ng t\u00edch c\u1ef1c h\u01a1n. M\u1ed9t trong s\u1ed1 \u0111\u00f3 l\u00e0 s\u1eed d\u1ee5ng Shrink API \u0111\u1ec3 l\u00e0m ph\u1eb3ng index th\u00e0nh m\u1ed9t shard ch\u00ednh duy nh\u1ea5t.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5: Thu nh\u1ecf index xu\u1ed1ng 1 shard:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">POST \/old_index\/_shrink\/shrunk_index<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"settings\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"index.number_of_shards\": 1<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Vi\u1ec7c c\u00f3 nhi\u1ec1u shards th\u01b0\u1eddng m\u1eb7c d\u00f9 t\u1ed1t, nh\u01b0ng c\u0169ng c\u00f3 th\u1ec3 g\u00e2y ra chi ph\u00ed ph\u1ee5 cho c\u00e1c index c\u0169 ch\u1ec9 nh\u1eadn \u0111\u01b0\u1ee3c c\u00e1c y\u00eau c\u1ea7u kh\u00f4ng th\u01b0\u1eddng xuy\u00ean. \u0110i\u1ec1u n\u00e0y ph\u1ee5 thu\u1ed9c r\u1ea5t nhi\u1ec1u v\u00e0o c\u1ea5u tr\u00fac d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n.<\/span><\/p>\n<h3><b>2. Frozen indices (\u0111\u00f3ng b\u0103ng index)<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u1ed1i v\u1edbi c\u00e1c index r\u1ea5t c\u0169 \u00edt khi \u0111\u01b0\u1ee3c truy c\u1eadp, vi\u1ec7c gi\u1ea3i ph\u00f3ng ho\u00e0n to\u00e0n b\u1ed9 nh\u1edb m\u00e0 ch\u00fang s\u1eed d\u1ee5ng l\u00e0 h\u1ee3p l\u00fd. Elasticsearch 6.6 tr\u1edf l\u00ean cung c\u1ea5p Freeze API cho ph\u00e9p b\u1ea1n th\u1ef1c hi\u1ec7n ch\u00ednh x\u00e1c \u0111i\u1ec1u \u0111\u00f3. Khi m\u1ed9t index b\u1ecb \u0111\u00f3ng b\u0103ng, index \u0111\u00f3 s\u1ebd tr\u1edf th\u00e0nh read-only v\u00e0 t\u00e0i nguy\u00ean c\u1ee7a index \u0111\u00f3 ng\u1eebng ho\u1ea1t \u0111\u1ed9ng.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">POST \/old_index\/_freeze<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">C\u00e1c index b\u1ecb \u0111\u00f3ng b\u0103ng t\u00ecm ki\u1ebfm ch\u1eadm h\u01a1n, v\u00ec c\u00e1c t\u00e0i nguy\u00ean \u0111\u00f3 b\u00e2y gi\u1edd ph\u1ea3i \u0111\u01b0\u1ee3c c\u1ea5p ph\u00e1t theo y\u00eau c\u1ea7u v\u00e0 sau \u0111\u00f3 b\u1ecb h\u1ee7y b\u1ecf. \u0110\u1ec3 ng\u0103n ch\u1eb7n t\u00ecnh tr\u1ea1ng ch\u1eadm truy v\u1ea5n c\u00f3 th\u1ec3 x\u1ea3y ra, tham s\u1ed1 truy v\u1ea5n <\/span><span style=\"font-weight: 400;\">ignore_throttled=false<\/span><span style=\"font-weight: 400;\"> ph\u1ea3i \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh r\u00f5 r\u00e0ng bao g\u1ed3m c\u00e1c index b\u1ecb \u0111\u00f3ng b\u0103ng khi x\u1eed l\u00fd truy v\u1ea5n t\u00ecm ki\u1ebfm.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/_search?ignore_throttled=false<\/span><\/pre>\n<h3><b>3. Qu\u1ea3n l\u00fd v\u00f2ng \u0111\u1eddi index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">T\u00ednh n\u0103ng Qu\u1ea3n l\u00fd v\u00f2ng \u0111\u1eddi index (ILM) \u0111\u01b0\u1ee3c ph\u00e1t h\u00e0nh trong Elasticsearch 6.7 cho ph\u00e9p b\u1ea1n t\u1ef1 \u0111\u1ed9ng h\u00f3a c\u00e1c qu\u00e1 tr\u00ecnh chuy\u1ec3n \u0111\u1ed5i. Trong c\u00e1c phi\u00ean b\u1ea3n Elasticsearch Stack tr\u01b0\u1edbc \u0111\u00f3, b\u1ea1n ph\u1ea3i th\u1ef1c hi\u1ec7n th\u1ee7 c\u00f4ng ho\u1eb7c s\u1eed d\u1ee5ng c\u00e1c quy tr\u00ecnh b\u00ean ngo\u00e0i.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">ILM c\u00f3 s\u1eb5n theo gi\u1ea5y ph\u00e9p c\u01a1 b\u1ea3n c\u1ee7a Elasticsearch, cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng ch\u1ec9 \u0111\u1ecbnh c\u00e1c ch\u00ednh s\u00e1ch x\u00e1c \u0111\u1ecbnh th\u1eddi \u0111i\u1ec3m di\u1ec5n ra c\u00e1c chuy\u1ec3n \u0111\u1ed5i n\u00e0y c\u0169ng nh\u01b0 c\u00e1c h\u00e0nh \u0111\u1ed9ng \u0111\u01b0\u1ee3c \u00e1p d\u1ee5ng trong t\u1eebng giai \u0111o\u1ea1n. B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ILM \u0111\u1ec3 thi\u1ebft l\u1eadp ki\u1ebfn tr\u00fac Hot-Warm-Cold, trong \u0111\u00f3 c\u00e1c giai \u0111o\u1ea1n c\u0169ng nh\u01b0 h\u00e0nh \u0111\u1ed9ng l\u00e0 t\u00f9y ch\u1ecdn v\u00e0 c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh n\u1ebfu c\u1ea7n:<\/span><\/p>\n<p><span style=\"font-weight: 400;\"><strong>Hot Index<\/strong> t\u00edch c\u1ef1c nh\u1eadn d\u1eef li\u1ec7u \u0111\u1ec3 l\u1eadp index v\u00e0 th\u01b0\u1eddng xuy\u00ean ph\u1ee5c v\u1ee5 c\u00e1c truy v\u1ea5n. C\u00e1c h\u00e0nh \u0111\u1ed9ng \u0111i\u1ec3n h\u00ecnh cho giai \u0111o\u1ea1n n\u00e0y bao g\u1ed3m:\u00a0<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">\u0110\u1eb7t m\u1ee9c \u0111\u1ed9 \u01b0u ti\u00ean cao cho vi\u1ec7c ph\u1ee5c h\u1ed3i;<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Ch\u1ec9 \u0111\u1ecbnh ch\u00ednh s\u00e1ch chuy\u1ec3n ti\u1ebfp \u0111\u1ec3 t\u1ea1o index m\u1edbi khi index hi\u1ec7n t\u1ea1i qu\u00e1 l\u1edbn, qu\u00e1 c\u0169 ho\u1eb7c c\u00f3 qu\u00e1 nhi\u1ec1u t\u00e0i li\u1ec7u.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><strong>Warm Index<\/strong> kh\u00f4ng c\u00f2n d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c l\u1eadp index trong \u0111\u00f3 n\u1eefa, nh\u01b0ng ch\u00fang v\u1eabn x\u1eed l\u00fd c\u00e1c truy v\u1ea5n. C\u00e1c h\u00e0nh \u0111\u1ed9ng \u0111i\u1ec3n h\u00ecnh cho giai \u0111o\u1ea1n n\u00e0y bao g\u1ed3m:\u00a0<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">\u0110\u1eb7t m\u1ee9c \u0111\u1ed9 \u01b0u ti\u00ean trung b\u00ecnh cho vi\u1ec7c ph\u1ee5c h\u1ed3i;<\/span><\/li>\n<li><span style=\"font-weight: 400;\">T\u1ed1i \u01b0u h\u00f3a c\u00e1c index b\u1eb1ng c\u00e1ch thu nh\u1ecf, h\u1ee3p nh\u1ea5t index ho\u1eb7c \u0111\u1eb7t ch\u00fang \u1edf ch\u1ebf \u0111\u1ed9 read-only;<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Ph\u00e2n b\u1ed5 index cho ph\u1ea7n c\u1ee9ng c\u00f3 hi\u1ec7u su\u1ea5t k\u00e9m h\u01a1n.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\"><strong>Cold Index<\/strong> hi\u1ebfm khi \u0111\u01b0\u1ee3c h\u1ecfi \u0111\u1ebfn v\u1edbi c\u00e1c h\u00e0nh \u0111\u1ed9ng \u0111i\u1ec3n h\u00ecnh cho giai \u0111o\u1ea1n n\u00e0y bao g\u1ed3m:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">\u0110\u1eb7t m\u1ee9c \u0111\u1ed9 \u01b0u ti\u00ean th\u1ea5p cho vi\u1ec7c ph\u1ee5c h\u1ed3i;<\/span><\/li>\n<li><span style=\"font-weight: 400;\">\u0110\u00f3ng b\u0103ng c\u00e1c ch\u1ec9 s\u1ed1;<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Ph\u00e2n b\u1ed5 c\u00e1c index cho ph\u1ea7n c\u1ee9ng c\u00f3 hi\u1ec7u su\u1ea5t k\u00e9m h\u01a1n;<\/span><\/li>\n<li><span style=\"font-weight: 400;\">X\u00f3a c\u00e1c index c\u0169 h\u01a1n theo th\u1eddi gian l\u01b0u gi\u1eef t\u00f9y \u00fd.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Ch\u00ednh s\u00e1ch ILM c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp b\u1eb1ng Elasticsearch REST API ho\u1eb7c tr\u1ef1c ti\u1ebfp trong Kibana, nh\u01b0 \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb trong \u1ea3nh ch\u1ee5p m\u00e0n h\u00ecnh sau:<\/span><\/p>\n<h3><b>4. T\u1ed5 ch\u1ee9c d\u1eef li\u1ec7u trong Elasticsearch Index<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Th\u00f4ng th\u01b0\u1eddng, vi\u1ec7c qu\u1ea3n l\u00fd m\u1ed9t Elasticsearch index ph\u1ea7n l\u1edbn t\u1eadp trung v\u00e0o vi\u1ec7c \u0111\u1ea3m b\u1ea3o t\u00ednh \u1ed5n \u0111\u1ecbnh v\u00e0 hi\u1ec7u su\u1ea5t. Tuy nhi\u00ean, c\u1ea5u tr\u00fac c\u1ee7a d\u1eef li\u1ec7u th\u1ef1c t\u1ebf \u0111i v\u00e0o c\u00e1c index n\u00e0y c\u0169ng l\u00e0 m\u1ed9t y\u1ebfu t\u1ed1 quan tr\u1ecdng \u0111\u1ed1i v\u1edbi t\u00ednh h\u1eefu d\u1ee5ng c\u1ee7a to\u00e0n b\u1ed9 h\u1ec7 th\u1ed1ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u1ea5u tr\u00fac n\u00e0y \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn \u0111\u1ed9 ch\u00ednh x\u00e1c v\u00e0 t\u00ednh linh ho\u1ea1t c\u1ee7a c\u00e1c truy v\u1ea5n t\u00ecm ki\u1ebfm tr\u00ean d\u1eef li\u1ec7u \u0111\u1ebfn t\u1eeb nhi\u1ec1u ngu\u1ed3n d\u1eef li\u1ec7u kh\u00e1c nhau. Do \u0111\u00f3 ch\u00fang c\u0169ng \u1ea3nh h\u01b0\u1edfng \u0111\u1ebfn c\u00e1ch b\u1ea1n ph\u00e2n t\u00edch v\u00e0 tr\u1ef1c quan h\u00f3a d\u1eef li\u1ec7u c\u1ee7a m\u00ecnh.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Tr\u00ean th\u1ef1c t\u1ebf, c\u00e1c chuy\u00ean gia khuy\u1ebfn ngh\u1ecb t\u1ea1o mapping (\u00e1nh x\u1ea1) cho c\u00e1c index \u0111\u00e3 t\u1ed3n t\u1ea1i t\u1eeb l\u00e2u. M\u1eb7c d\u00f9 Elasticsearch c\u00f3 kh\u1ea3 n\u0103ng \u0111o\u00e1n ki\u1ec3u d\u1eef li\u1ec7u d\u1ef1a tr\u00ean d\u1eef li\u1ec7u \u0111\u1ea7u v\u00e0o nh\u1eadn \u0111\u01b0\u1ee3c, nh\u01b0ng \u0111i\u1ec1u n\u00e0y ch\u1ec9 d\u1ef1a tr\u00ean m\u1ed9t sample nh\u1ecf c\u1ee7a t\u1eadp d\u1eef li\u1ec7u v\u00e0 c\u00f3 th\u1ec3 kh\u00f4ng ch\u00ednh x\u00e1c. Vi\u1ec7c t\u1ea1o \u00e1nh x\u1ea1 r\u00f5 r\u00e0ng s\u1ebd ng\u0103n ng\u1eeba c\u00e1c v\u1ea5n \u0111\u1ec1 xung \u0111\u1ed9t ki\u1ec3u d\u1eef li\u1ec7u trong m\u1ed9t index.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ngay c\u1ea3 v\u1edbi mapping, vi\u1ec7c thu th\u1eadp th\u00f4ng tin chi ti\u1ebft t\u1eeb kh\u1ed1i l\u01b0\u1ee3ng d\u1eef li\u1ec7u l\u01b0u tr\u1eef trong m\u1ed9t Elasticsearch cluster v\u1eabn c\u00f3 th\u1ec3 l\u00e0 m\u1ed9t nhi\u1ec7m v\u1ee5 kh\u00f3 kh\u0103n. D\u1eef li\u1ec7u \u0111\u1ebfn t\u1eeb c\u00e1c ngu\u1ed3n kh\u00e1c nhau c\u00f3 th\u1ec3 c\u00f3 c\u1ea5u tr\u00fac t\u01b0\u01a1ng t\u1ef1 (v\u00ed d\u1ee5: \u0111\u1ecba ch\u1ec9 IP \u0111\u1ebfn t\u1eeb IIS, NGINX v\u00e0 nh\u1eadt k\u00fd \u1ee9ng d\u1ee5ng) c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c l\u1eadp index v\u00e0o c\u00e1c tr\u01b0\u1eddng c\u00f3 name ho\u1eb7c ki\u1ec3u d\u1eef li\u1ec7u ho\u00e0n to\u00e0n kh\u00e1c nhau.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Elastic Common Schema (ECS), \u0111\u01b0\u1ee3c ph\u00e1t h\u00e0nh c\u00f9ng v\u1edbi Elasticsearch 7.x, l\u00e0 m\u1ed9t ph\u00e1t tri\u1ec3n m\u1edbi trong l\u0129nh v\u1ef1c n\u00e0y. B\u1eb1ng c\u00e1ch \u0111\u1eb7t m\u1ed9t ti\u00eau chu\u1ea9n \u0111\u1ec3 h\u1ee3p nh\u1ea5t t\u00ean tr\u01b0\u1eddng v\u00e0 ki\u1ec3u d\u1eef li\u1ec7u, vi\u1ec7c t\u00ecm ki\u1ebfm v\u00e0 tr\u1ef1c quan h\u00f3a d\u1eef li\u1ec7u \u0111\u1ebfn t\u1eeb nhi\u1ec1u ngu\u1ed3n kh\u00e1c nhau tr\u1edf n\u00ean d\u1ec5 d\u00e0ng h\u01a1n nhi\u1ec1u. ECS c\u0169ng cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng t\u1eadn d\u1ee5ng Kibana \u0111\u1ec3 c\u00f3 m\u1ed9t ch\u1ebf \u0111\u1ed9 xem th\u1ed1ng nh\u1ea5t c\u1ee7a c\u00e1c h\u1ec7 th\u1ed1ng ri\u00eang bi\u1ec7t m\u00e0 b\u1ea1n \u0111ang duy tr\u00ec.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_thuong_gap_ve_delete_index_Elasticsearch\"><\/span><b>C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 delete index Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>X\u00f3a Index theo truy v\u1ea5n v\u00e0 x\u00f3a h\u00e0ng lo\u1ea1t trong Elasticsearch kh\u00e1c nhau nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong qu\u00e1 tr\u00ecnh x\u1eed l\u00fd y\u00eau c\u1ea7u x\u00f3a theo truy v\u1ea5n, Elasticsearch th\u1ef1c hi\u1ec7n tu\u1ea7n t\u1ef1 nhi\u1ec1u y\u00eau c\u1ea7u t\u00ecm ki\u1ebfm \u0111\u1ec3 t\u00ecm t\u1ea5t c\u1ea3 c\u00e1c t\u00e0i li\u1ec7u ph\u00f9 h\u1ee3p c\u1ea7n x\u00f3a. Trong khi \u0111\u00f3, y\u00eau c\u1ea7u x\u00f3a h\u00e0ng lo\u1ea1t \u0111\u01b0\u1ee3c th\u1ef1c hi\u1ec7n cho m\u1ed7i l\u00f4 t\u00e0i li\u1ec7u ph\u00f9 h\u1ee3p.<\/span><\/p>\n<h3><b>X\u00f3a nhi\u1ec1u Index nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 x\u00f3a nhi\u1ec1u index c\u00f9ng l\u00fac b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng wildcard ho\u1eb7c danh s\u00e1ch t\u00ean index \u0111\u01b0\u1ee3c ph\u00e2n c\u00e1ch b\u1eb1ng d\u1ea5u ph\u1ea9y. V\u00ed d\u1ee5: \u0111\u1ec3 x\u00f3a t\u1ea5t c\u1ea3 c\u00e1c index b\u1eaft \u0111\u1ea7u b\u1eb1ng &#8220;logstash&#8221;:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl -X DELETE \"http:\/\/localhost:9200\/logstash*\"<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Ho\u1eb7c, \u0111\u1ec3 x\u00f3a c\u00e1c index c\u1ee5 th\u1ec3, h\u00e3y ph\u00e2n t\u00e1ch ch\u00fang b\u1eb1ng d\u1ea5u ph\u1ea9y:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl -X DELETE \"http:\/\/localhost:9200\/index1,index2,index3\"<\/span><\/pre>\n<h3><b>X\u00f3a t\u1ea5t c\u1ea3 c\u00e1c t\u00e0i li\u1ec7u kh\u1ecfi Index nh\u01b0 th\u1ebf n\u00e0o?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 x\u00f3a t\u1ea5t c\u1ea3 c\u00e1c t\u00e0i li\u1ec7u kh\u1ecfi index b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">_delete_by_query<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Khi s\u1eed d\u1ee5ng truy v\u1ea5n <\/span><span style=\"font-weight: 400;\">\u201cmatch_all\u201d:{}<\/span><span style=\"font-weight: 400;\"> h\u1ec7 th\u1ed1ng s\u1ebd th\u1ef1c hi\u1ec7n so kh\u1edbp v\u1edbi t\u1ea5t c\u1ea3 c\u00e1c document c\u00f3 trong index. Do \u0111\u00f3, thao t\u00e1c <\/span><span style=\"font-weight: 400;\">_delete_by_query<\/span><span style=\"font-weight: 400;\"> s\u1ebd ti\u1ebfn h\u00e0nh x\u00f3a to\u00e0n b\u1ed9 c\u00e1c document n\u00e0y kh\u1ecfi index.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">POST document-index\/_delete_by_query?conflicts=proceed<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\"match_all\": {}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket_delete_index_Elasticsearch\"><\/span><b>T\u1ed5ng k\u1ebft delete index Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">X\u00f3a index trong Elasticsearch l\u00e0 m\u1ed9t thao t\u00e1c quan tr\u1ecdng \u0111\u1ec3 qu\u1ea3n l\u00fd d\u1eef li\u1ec7u v\u00e0 t\u1ed1i \u01b0u h\u00f3a hi\u1ec7u su\u1ea5t h\u1ec7 th\u1ed1ng. B\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng API ho\u1eb7c Kibana \u0111\u1ec3 th\u1ef1c hi\u1ec7n vi\u1ec7c n\u00e0y m\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng ho\u1eb7c m\u1ed9t s\u1ed1 c\u00e1ch th\u1ee7 c\u00f4ng t\u00f9y ho\u00e0n c\u1ea3nh. Tuy nhi\u00ean, h\u00e3y lu\u00f4n c\u1ea9n tr\u1ecdng v\u00e0 \u0111\u1ea3m b\u1ea3o b\u1ea1n \u0111\u00e3 sao l\u01b0u d\u1eef li\u1ec7u c\u1ea7n thi\u1ebft tr\u01b0\u1edbc khi x\u00f3a index, v\u00ec thao t\u00e1c n\u00e0y l\u00e0 kh\u00f4ng th\u1ec3 ph\u1ee5c h\u1ed3i. \u0110\u1ed3ng th\u1eddi, vi\u1ec7c hi\u1ec3u r\u00f5 c\u00e1c t\u00f9y ch\u1ecdn v\u00e0 tham s\u1ed1 li\u00ean quan s\u1ebd gi\u00fap b\u1ea1n x\u00f3a index m\u1ed9t c\u00e1ch ch\u00ednh x\u00e1c v\u00e0 an to\u00e0n.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Trong qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng Elasticsearch, \u0111\u00f4i khi b\u1ea1n c\u1ea7n x\u00f3a c\u00e1c Index kh\u00f4ng c\u00f2n c\u1ea7n thi\u1ebft \u0111\u1ec3 gi\u1ea3i ph\u00f3ng dung l\u01b0\u1ee3ng l\u01b0u tr\u1eef ho\u1eb7c \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c qu\u1ea3n l\u00fd d\u1eef li\u1ec7u. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd h\u01b0\u1edbng d\u1eabn b\u1ea1n t\u1eebng b\u01b0\u1edbc c\u00e1ch delete Index Elasticsearch, t\u1eeb nh\u1eefng thao t\u00e1c c\u01a1 b\u1ea3n \u0111\u1ebfn c\u00e1c ph\u01b0\u01a1ng [&hellip;]<\/p>\n","protected":false},"author":205,"featured_media":87337,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109],"tags":[],"class_list":["post-87947","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n - ITviec Blog<\/title>\n<meta name=\"description\" content=\"T\u00ecm hi\u1ec3u c\u00e1c c\u00e1ch delete index Elasticsearch, k\u1ebft h\u1ee3p c\u00e1ch qu\u1ea3n l\u00fd index hi\u1ec7u qu\u1ea3 \u0111\u1ec3 t\u1ed1i \u01b0u h\u1ec7 th\u1ed1ng. Xem h\u01b0\u1edbng d\u1eabn v\u00e0 b\u1eaft \u0111\u1ea7u l\u00e0m ngay!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n\" \/>\n<meta property=\"og:description\" content=\"Trong qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng Elasticsearch, \u0111\u00f4i khi b\u1ea1n c\u1ea7n x\u00f3a c\u00e1c Index kh\u00f4ng c\u00f2n c\u1ea7n thi\u1ebft \u0111\u1ec3 gi\u1ea3i ph\u00f3ng dung l\u01b0\u1ee3ng l\u01b0u tr\u1eef ho\u1eb7c \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c qu\u1ea3n l\u00fd\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-12T15:06:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-17T07:47:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/04\/delete-index-elasticsearch-vippro-scaled.png\" \/>\n\t<meta property=\"og:image:width\" content=\"640\" \/>\n\t<meta property=\"og:image:height\" content=\"337\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"H\u00e0 My\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"H\u00e0 My\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"17 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n - ITviec Blog","description":"T\u00ecm hi\u1ec3u c\u00e1c c\u00e1ch delete index Elasticsearch, k\u1ebft h\u1ee3p c\u00e1ch qu\u1ea3n l\u00fd index hi\u1ec7u qu\u1ea3 \u0111\u1ec3 t\u1ed1i \u01b0u h\u1ec7 th\u1ed1ng. Xem h\u01b0\u1edbng d\u1eabn v\u00e0 b\u1eaft \u0111\u1ea7u l\u00e0m ngay!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/","og_locale":"vi_VN","og_type":"article","og_title":"Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n","og_description":"Trong qu\u00e1 tr\u00ecnh s\u1eed d\u1ee5ng Elasticsearch, \u0111\u00f4i khi b\u1ea1n c\u1ea7n x\u00f3a c\u00e1c Index kh\u00f4ng c\u00f2n c\u1ea7n thi\u1ebft \u0111\u1ec3 gi\u1ea3i ph\u00f3ng dung l\u01b0\u1ee3ng l\u01b0u tr\u1eef ho\u1eb7c \u0111\u01a1n gi\u1ea3n h\u00f3a vi\u1ec7c qu\u1ea3n l\u00fd","og_url":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-04-12T15:06:59+00:00","article_modified_time":"2025-06-17T07:47:19+00:00","og_image":[{"width":640,"height":337,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/04\/delete-index-elasticsearch-vippro-scaled.png","type":"image\/png"}],"author":"H\u00e0 My","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"H\u00e0 My","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"17 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/"},"author":{"name":"H\u00e0 My","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/7bd099db44e5079508c9b7e8c0161e3c"},"headline":"Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n","datePublished":"2025-04-12T15:06:59+00:00","dateModified":"2025-06-17T07:47:19+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/"},"wordCount":4602,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/04\/delete-index-elasticsearch-vippro-scaled.png","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/","url":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/","name":"Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/04\/delete-index-elasticsearch-vippro-scaled.png","datePublished":"2025-04-12T15:06:59+00:00","dateModified":"2025-06-17T07:47:19+00:00","description":"T\u00ecm hi\u1ec3u c\u00e1c c\u00e1ch delete index Elasticsearch, k\u1ebft h\u1ee3p c\u00e1ch qu\u1ea3n l\u00fd index hi\u1ec7u qu\u1ea3 \u0111\u1ec3 t\u1ed1i \u01b0u h\u1ec7 th\u1ed1ng. Xem h\u01b0\u1edbng d\u1eabn v\u00e0 b\u1eaft \u0111\u1ea7u l\u00e0m ngay!","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/04\/delete-index-elasticsearch-vippro-scaled.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/04\/delete-index-elasticsearch-vippro-scaled.png","width":640,"height":337,"caption":"delete index elasticsearch - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/huong-dan-delete-index-elasticsearch\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"Delete index Elasticsearch: C\u00e1ch l\u00e0m hi\u1ec7u qu\u1ea3 v\u00e0 an to\u00e0n"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/7bd099db44e5079508c9b7e8c0161e3c","name":"H\u00e0 My","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ha-my-author-e1709882319892-100x100.jpeg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ha-my-author-e1709882319892-100x100.jpeg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/03\/ha-my-author-e1709882319892-100x100.jpeg","caption":"H\u00e0 My"},"url":"https:\/\/itviec.com\/blog\/author\/ha-my\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87947","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/205"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=87947"}],"version-history":[{"count":1,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87947\/revisions"}],"predecessor-version":[{"id":88186,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/87947\/revisions\/88186"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/87337"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=87947"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=87947"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=87947"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}