{"id":85446,"date":"2025-03-31T15:16:36","date_gmt":"2025-03-31T08:16:36","guid":{"rendered":"https:\/\/itviecblog.uptech.vn\/?p=85446"},"modified":"2025-06-17T09:12:49","modified_gmt":"2025-06-17T02:12:49","slug":"huong-dan-elasticsearch-tutorial","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/","title":{"rendered":"Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_85 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-elasticsearch-tutorial\/#Hieu_ro_cac_khai_niem_cua_Elasticsearch\" >Hi\u1ec3u r\u00f5 c\u00e1c kh\u00e1i ni\u1ec7m c\u1ee7a Elasticsearch<\/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-elasticsearch-tutorial\/#Thiet_lap_Elasticsearch_nhu_the_nao\" >Thi\u1ebft l\u1eadp Elasticsearch nh\u01b0 th\u1ebf n\u00e0o?<\/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-elasticsearch-tutorial\/#Elasticsearch_tutorial_Cach_lap_chi_muc_va_truy_van_du_lieu_trong_Elasticsearch\" >Elasticsearch tutorial: C\u00e1ch l\u1eadp ch\u1ec9 m\u1ee5c v\u00e0 truy v\u1ea5n d\u1eef li\u1ec7u trong Elasticsearch<\/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-elasticsearch-tutorial\/#Elasticsearch_tutorial_Cach_tim_kiem_du_lieu_co_ban_trong_Elasticsearch\" >Elasticsearch tutorial: C\u00e1ch t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u c\u01a1 b\u1ea3n trong Elasticsearch<\/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-elasticsearch-tutorial\/#Elasticsearch_tutorial_Cach_tim_kiem_nang_cao_trong_Elasticsearch\" >Elasticsearch tutorial: C\u00e1ch t\u00ecm ki\u1ebfm n\u00e2ng cao 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-elasticsearch-tutorial\/#Elasticsearch_tutorial_Cach_ket_hop_cac_truy_van_trong_Elasticsearch\" >Elasticsearch tutorial: C\u00e1ch k\u1ebft h\u1ee3p c\u00e1c truy v\u1ea5n trong Elasticsearch<\/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-elasticsearch-tutorial\/#Elasticsearch_tutorial_Cach_giam_sat_va_toi_uu_hoa_trong_Elasticsearch\" >Elasticsearch tutorial: C\u00e1ch gi\u00e1m s\u00e1t v\u00e0 t\u1ed1i \u01b0u h\u00f3a trong 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-elasticsearch-tutorial\/#Elasticsearch_tutorial_Cach_kiem_soat_an_ninh_va_truy_cap\" >Elasticsearch tutorial: C\u00e1ch ki\u1ec3m so\u00e1t an ninh v\u00e0 truy c\u1eadp<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#Cau_hoi_thuong_gap_ve_Elasticsearch_tutorial\" >C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 Elasticsearch tutorial<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#Tong_ket_Elasticsearch_tutorial\" >T\u1ed5ng k\u1ebft Elasticsearch tutorial<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>B\u1ea1n mu\u1ed1n t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u si\u00eau t\u1ed1c, ph\u00e2n t\u00edch l\u01b0\u1ee3ng th\u00f4ng tin kh\u1ed5ng l\u1ed3 v\u00e0 x\u00e2y d\u1ef1ng \u1ee9ng d\u1ee5ng m\u1ea1nh m\u1ebd? Elasticsearch l\u00e0 c\u00f4ng c\u1ee5 s\u1ebd bi\u1ebfn d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n th\u00e0nh s\u1ee9c m\u1ea1nh, cho ph\u00e9p b\u1ea1n kh\u00e1m ph\u00e1 th\u00f4ng tin ch\u1ec9 trong \u201ct\u00edch t\u1eafc\u201d. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd xoay quanh c\u00e1c Elasticsearch tutorial &#8211; h\u01b0\u1edbng d\u1eabn chi ti\u1ebft nh\u1eefng b\u01b0\u1edbc \u0111\u1ea7u ti\u00ean \u0111\u1ec3 l\u00e0m ch\u1ee7 Elasticsearch, ph\u00f9 h\u1ee3p v\u1edbi Developer, Data Engineer v\u00e0 IT Administrator mu\u1ed1n t\u00ecm hi\u1ec3u t\u1eeb c\u01a1 b\u1ea3n v\u1ec1 Elasticsearch.<\/strong><\/em><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ecdc b\u00e0i vi\u1ebft \u0111\u1ec3 n\u1eafm r\u00f5:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1c kh\u00e1i ni\u1ec7m c\u1ee7a Elasticsearch<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1ch thi\u1ebft l\u1eadp Elasticsearch<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1ch l\u1eadp ch\u1ec9 m\u1ee5c v\u00e0 truy v\u1ea5n d\u1eef li\u1ec7u trong Elasticsearch<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1ch t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u Elasticsearch v\u00e0 t\u00ednh n\u0103ng t\u00ecm ki\u1ebfm n\u00e2ng cao<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Gi\u00e1m s\u00e1t v\u00e0 t\u1ed1i \u01b0u h\u00f3a trong Elasticsearch<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ki\u1ec3m so\u00e1t an ninh v\u00e0 truy c\u1eadp trong Elasticsearch<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Hieu_ro_cac_khai_niem_cua_Elasticsearch\"><\/span><b>Hi\u1ec3u r\u00f5 c\u00e1c kh\u00e1i ni\u1ec7m c\u1ee7a Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><b>Elasticsearch<\/b><span style=\"font-weight: 400;\"> l\u00e0 m\u1ed9t c\u00f4ng c\u1ee5 t\u00ecm ki\u1ebfm v\u00e0 ph\u00e2n t\u00edch ph\u00e2n t\u00e1n, m\u00e3 ngu\u1ed3n m\u1edf, \u0111\u01b0\u1ee3c x\u00e2y d\u1ef1ng tr\u00ean Apache Lucene. Elasticsearch th\u01b0\u1eddng l\u00e0 th\u00e0nh ph\u1ea7n c\u1ed1t l\u00f5i trong Elastic Stack (tr\u01b0\u1edbc \u0111\u00e2y g\u1ecdi l\u00e0 ELK Stack), k\u1ebft h\u1ee3p v\u1edbi Kibana, Logstash v\u00e0 Beats.<\/span><\/li>\n<li><b>Node:<\/b><span style=\"font-weight: 400;\"> Node l\u00e0 m\u1ed9t phi\u00ean b\u1ea3n \u0111\u01a1n l\u1ebb c\u1ee7a Elasticsearch \u0111ang ch\u1ea1y. Trong Elasticsearch 8.x, m\u1ed7i node c\u00f3 vai tr\u00f2 c\u1ee5 th\u1ec3 v\u00e0 \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh m\u1eb7c \u0111\u1ecbnh \u0111\u1ec3 ph\u00f9 h\u1ee3p v\u1edbi b\u1ea3o m\u1eadt. K\u1ec3 t\u1eeb phi\u00ean b\u1ea3n 7.x, c\u00e1c node ph\u1ea3i \u0111\u01b0\u1ee3c x\u00e1c th\u1ef1c \u0111\u1ec3 tham gia v\u00e0o cluster th\u00f4ng qua c\u00e1c certificates, v\u00e0 Transport Layer Security (TLS) \u0111\u01b0\u1ee3c b\u1eadt theo m\u1eb7c \u0111\u1ecbnh cho giao ti\u1ebfp gi\u1eefa c\u00e1c node. M\u1ed9t m\u00e1y v\u1eadt l\u00fd ho\u1eb7c m\u00e1y \u1ea3o c\u00f3 th\u1ec3 ch\u1ea1y nhi\u1ec1u node, nh\u01b0ng th\u00f4ng th\u01b0\u1eddng m\u1ed7i m\u00e1y ch\u1ec9 ch\u1ea1y m\u1ed9t node trong m\u00f4i tr\u01b0\u1eddng production.<\/span><\/li>\n<li><b>Cluster:<\/b><span style=\"font-weight: 400;\"> \u0110\u00e2y l\u00e0 t\u1eadp h\u1ee3p m\u1ed9t ho\u1eb7c nhi\u1ec1u node c\u00f9ng chia s\u1ebb c\u00f9ng m\u1ed9t cluster name. Cluster cung c\u1ea5p kh\u1ea3 n\u0103ng l\u1eadp ch\u1ec9 m\u1ee5c v\u00e0 t\u00ecm ki\u1ebfm t\u1eadp th\u1ec3 t\u1ea5t c\u1ea3 c\u00e1c node cho to\u00e0n b\u1ed9 d\u1eef li\u1ec7u.<\/span><\/li>\n<li><b>Index:<\/b><span style=\"font-weight: 400;\"> \u0110\u00e2y l\u00e0 t\u1eadp h\u1ee3p c\u00e1c lo\u1ea1i t\u00e0i li\u1ec7u kh\u00e1c nhau v\u00e0 thu\u1ed9c t\u00ednh c\u1ee7a ch\u00fang. Index c\u0169ng s\u1eed d\u1ee5ng kh\u00e1i ni\u1ec7m ph\u00e2n m\u1ea3nh (shard) \u0111\u1ec3 c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t. V\u00ed d\u1ee5, m\u1ed9t t\u1eadp h\u1ee3p t\u00e0i li\u1ec7u ch\u1ee9a d\u1eef li\u1ec7u t\u1eeb m\u1ed9t \u1ee9ng d\u1ee5ng m\u1ea1ng x\u00e3 h\u1ed9i s\u1ebd \u0111\u01b0\u1ee3c ph\u00e2n chia th\u00e0nh nhi\u1ec1u shard \u0111\u1ec3 cho ph\u00e9p x\u1eed l\u00fd song song v\u00e0 t\u0103ng t\u1ed1c \u0111\u1ed9 truy v\u1ea5n.<\/span><\/li>\n<li><b>Document:<\/b><span style=\"font-weight: 400;\"> \u0110\u00e2y l\u00e0 m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c tr\u01b0\u1eddng c\u1ee5 th\u1ec3 theo \u0111\u1ecbnh d\u1ea1ng JSON. M\u1ed7i t\u00e0i li\u1ec7u \u0111\u01b0\u1ee3c ph\u00e2n lo\u1ea1i theo m\u1ed9t ki\u1ec3u d\u1eef li\u1ec7u c\u1ee5 th\u1ec3 v\u00e0 \u0111\u01b0\u1ee3c l\u01b0u tr\u1eef trong m\u1ed9t ch\u1ec9 m\u1ee5c (index). T\u1eeb Elasticsearch 7.0, kh\u00e1i ni\u1ec7m &#8220;type&#8221; \u0111\u00e3 b\u1ecb lo\u1ea1i b\u1ecf d\u1ea7n v\u00e0 ho\u00e0n to\u00e0n bi\u1ebfn m\u1ea5t trong Elasticsearch 8.x. M\u1ed7i document c\u00f3 m\u1ed9t ID duy nh\u1ea5t v\u00e0 m\u1ed9t t\u1eadp h\u1ee3p c\u00e1c fields c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c l\u1eadp index (\u0111\u00e1nh ch\u1ec9 m\u1ee5c) \u0111\u1ec3 t\u00ecm ki\u1ebfm. Elasticsearch 8.x h\u1ed7 tr\u1ee3 nhi\u1ec1u lo\u1ea1i d\u1eef li\u1ec7u phong ph\u00fa h\u01a1n, bao g\u1ed3m c\u00e1c lo\u1ea1i ph\u1ee9c t\u1ea1p nh\u01b0 geo_point, nested objects, v\u00e0 dense_vector cho machine learning.<\/span><\/li>\n<li><b>Shard:<\/b><span style=\"font-weight: 400;\"> C\u00e1c index \u0111\u01b0\u1ee3c ph\u00e2n v\u00f9ng theo chi\u1ec1u ngang th\u00e0nh c\u00e1c \u0111\u01a1n v\u1ecb nh\u1ecf h\u01a1n g\u1ecdi l\u00e0 ph\u00e2n m\u1ea3nh (shard). M\u1ed7i ph\u00e2n m\u1ea3nh n\u00e0y gi\u1eef nguy\u00ean c\u1ea5u tr\u00fac d\u1eef li\u1ec7u, bao g\u1ed3m t\u1ea5t c\u1ea3 c\u00e1c thu\u1ed9c t\u00ednh c\u1ee7a t\u00e0i li\u1ec7u, nh\u01b0ng ch\u1ec9 \u00edt \u0111\u1ed1i t\u01b0\u1ee3ng JSON so v\u1edbi index g\u1ed1c. S\u1ef1 ph\u00e2n chia n\u00e0y t\u1ea1o ra c\u00e1c ph\u00e2n m\u1ea3nh \u0111\u1ed9c l\u1eadp, cho ph\u00e9p ph\u00e2n ph\u1ed1i d\u1eef li\u1ec7u v\u00e0 x\u1eed l\u00fd song song tr\u00ean nhi\u1ec1u node. Primary shard \u0111\u1ea1i di\u1ec7n cho ph\u1ea7n d\u1eef li\u1ec7u g\u1ed1c \u0111\u01b0\u1ee3c ph\u00e2n chia t\u1eeb index, v\u00e0 \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o s\u1eb5n s\u00e0ng v\u00e0 kh\u1ea3 n\u0103ng ch\u1ecbu l\u1ed7i, c\u00e1c primary shard n\u00e0y \u0111\u01b0\u1ee3c sao ch\u00e9p th\u00e0nh c\u00e1c ph\u00e2n m\u1ea3nh b\u1ea3n sao (replica shards).<\/span><\/li>\n<li><b>Replicas:<\/b><span style=\"font-weight: 400;\"> Elasticsearch cho ph\u00e9p ng\u01b0\u1eddi d\u00f9ng t\u1ea1o b\u1ea3n sao c\u1ee7a c\u00e1c index v\u00e0 shard c\u1ee7a ch\u00fang. \u0110i\u1ec1u n\u00e0y kh\u00f4ng ch\u1ec9 gi\u00fap t\u0103ng t\u00ednh kh\u1ea3 d\u1ee5ng c\u1ee7a d\u1eef li\u1ec7u trong tr\u01b0\u1eddng h\u1ee3p x\u1ea3y ra l\u1ed7i m\u00e0 c\u00f2n c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t t\u00ecm ki\u1ebfm b\u1eb1ng c\u00e1ch th\u1ef1c hi\u1ec7n thao t\u00e1c t\u00ecm ki\u1ebfm song song trong c\u00e1c replicas n\u00e0y.<\/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=\"Thiet_lap_Elasticsearch_nhu_the_nao\"><\/span><b>Thi\u1ebft l\u1eadp Elasticsearch nh\u01b0 th\u1ebf n\u00e0o?<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>B\u01b0\u1edbc 1: Ki\u1ec3m tra y\u00eau c\u1ea7u Java<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Tr\u01b0\u1edbc khi c\u00e0i \u0111\u1eb7t Elasticsearch, b\u1ea1n c\u1ea7n \u0111\u1ea3m b\u1ea3o h\u1ec7 th\u1ed1ng c\u00f3 phi\u00ean b\u1ea3n Java ph\u00f9 h\u1ee3p:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elasticsearch 8.x (phi\u00ean b\u1ea3n m\u1edbi nh\u1ea5t) y\u00eau c\u1ea7u Java 17 tr\u1edf l\u00ean<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elasticsearch 7.x y\u00eau c\u1ea7u Java 11 tr\u1edf l\u00ean<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">T\u1eeb phi\u00ean b\u1ea3n 7.0 tr\u1edf \u0111i, Elasticsearch \u0111\u00e3 t\u00edch h\u1ee3p s\u1eb5n OpenJDK, n\u00ean b\u1ea1n kh\u00f4ng c\u1ea7n c\u00e0i Java ri\u00eang tr\u1eeb khi mu\u1ed1n s\u1eed d\u1ee5ng m\u1ed9t phi\u00ean b\u1ea3n c\u1ee5 th\u1ec3. N\u1ebfu c\u1ea7n, b\u1ea1n c\u00f3 th\u1ec3 \u0111\u1eb7t bi\u1ebfn m\u00f4i tr\u01b0\u1eddng ES_JAVA_HOME \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh JDK mong mu\u1ed1n.<\/span><\/p>\n<p><b>C\u00e1ch ki\u1ec3m tra phi\u00ean b\u1ea3n Java:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Trong H\u1ec7 \u0111i\u1ec1u h\u00e0nh Windows (OS), s\u1eed d\u1ee5ng d\u1ea5u nh\u1eafc l\u1ec7nh:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">java -version<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Trong h\u1ec7 \u0111i\u1ec1u h\u00e0nh UNIX, s\u1eed d\u1ee5ng Terminal:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">java -version<\/span>\n\n<span style=\"font-weight: 400;\">echo $JAVA_HOME<\/span><\/pre>\n<h3><b>B\u01b0\u1edbc 2: T\u1ea3i xu\u1ed1ng Elasticsearch<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">H\u01b0\u1edbng d\u1eabn n\u00e0y s\u1eed d\u1ee5ng Elasticsearch 8.11.x (phi\u00ean b\u1ea3n m\u1edbi nh\u1ea5t t\u00ednh \u0111\u1ebfn th\u00e1ng 3\/2025). C\u00e1c phi\u00ean b\u1ea3n tr\u01b0\u1edbc c\u00f3 th\u1ec3 c\u00f3 m\u1ed9t s\u1ed1 kh\u00e1c bi\u1ec7t v\u1ec1 c\u00fa ph\u00e1p v\u00e0 t\u00ednh n\u0103ng. N\u1ebfu b\u1ea1n \u0111ang s\u1eed d\u1ee5ng phi\u00ean b\u1ea3n c\u0169 h\u01a1n, h\u00e3y tham kh\u1ea3o t\u00e0i li\u1ec7u ch\u00ednh th\u1ee9c t\u1ea1i<\/span> <a href=\"https:\/\/www.elastic.co\/guide\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">elastic.co\/guide<\/span><\/a><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">L\u01b0u \u00fd quan tr\u1ecdng v\u1ec1 t\u01b0\u01a1ng th\u00edch:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elasticsearch 8.x c\u00f3 thay \u0111\u1ed5i \u0111\u00e1ng k\u1ec3 so v\u1edbi 7.x, \u0111\u1eb7c bi\u1ec7t l\u00e0 v\u1ec1 b\u1ea3o m\u1eadt (b\u1eadt m\u1eb7c \u0111\u1ecbnh) v\u00e0 API.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Vi\u1ec7c n\u00e2ng c\u1ea5p t\u1eeb 7.x l\u00ean 8.x c\u1ea7n \u0111\u01b0\u1ee3c l\u00ean k\u1ebf ho\u1ea1ch k\u1ef9 l\u01b0\u1ee1ng v\u00e0 tu\u00e2n theo h\u01b0\u1edbng d\u1eabn n\u00e2ng c\u1ea5p ch\u00ednh th\u1ee9c.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Ch\u1ecdn phi\u00ean b\u1ea3n c\u00e0i \u0111\u1eb7t ph\u00f9 h\u1ee3p v\u1edbi h\u1ec7 \u0111i\u1ec1u h\u00e0nh:<\/span><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">Windows: T\u1ea3i v\u1ec1 t\u1ec7p .ZIP<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Mac\/Linux: T\u1ea3i v\u1ec1 t\u1ec7p .TAR<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Linux d\u1ef1a tr\u00ean Debian (Ubuntu, Debian,&#8230;): T\u1ea3i v\u1ec1 t\u1ec7p .DEB<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Linux d\u1ef1a tr\u00ean Red Hat (RHEL, CentOS, Fedora,&#8230;): T\u1ea3i v\u1ec1 t\u1ec7p .RPM<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Ngo\u00e0i ra, c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng ti\u1ec7n \u00edch APT v\u00e0 YUM \u0111\u1ec3 c\u00e0i \u0111\u1eb7t tr\u00ean c\u00e1c b\u1ea3n ph\u00e2n ph\u1ed1i Linux.<\/span><\/li>\n<\/ul>\n<h3><b>B\u01b0\u1edbc 3: C\u00e0i \u0111\u1eb7t Elasticsearch<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Qu\u00e1 tr\u00ecnh c\u00e0i \u0111\u1eb7t Elasticsearch r\u1ea5t \u0111\u01a1n gi\u1ea3n v\u00e0 \u0111\u01b0\u1ee3c m\u00f4 t\u1ea3 nh\u01b0 sau cho c\u00e1c h\u1ec7 \u0111i\u1ec1u h\u00e0nh kh\u00e1c nhau:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u1ec7 \u0111i\u1ec1u h\u00e0nh Windows \u2212 Gi\u1ea3i n\u00e9n g\u00f3i zip v\u00e0 Elasticsearch s\u1ebd \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u1ec7 \u0111i\u1ec1u h\u00e0nh UNIX \u2212 Gi\u1ea3i n\u00e9n t\u1ec7p tar \u1edf b\u1ea5t k\u1ef3 v\u1ecb tr\u00ed n\u00e0o v\u00e0 Elasticsearch s\u1ebd \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">wget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-8.11.1-linux-x86_64.tar.gz<\/span>\n\n<span style=\"font-weight: 400;\">tar -xzf elasticsearch-8.11.1-linux-x86_64.tar.gz<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng ti\u1ec7n \u00edch APT cho h\u1ec7 \u0111i\u1ec1u h\u00e0nh Linux \u2212 T\u1ea3i xu\u1ed1ng v\u00e0 c\u00e0i \u0111\u1eb7t Public Signing Key:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">wget -qO - https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch | sudo gpg --dearmor -o \/usr\/share\/keyrings\/elasticsearch-keyring.gpg<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">L\u01b0u \u0111\u1ecbnh ngh\u0129a kho l\u01b0u tr\u1eef nh\u01b0 sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">echo \"deb [signed-by=\/usr\/share\/keyrings\/elasticsearch-keyring.gpg] https:\/\/artifacts.elastic.co\/packages\/8.x\/apt stable main\" | sudo tee \/etc\/apt\/sources.list.d\/elastic-8.x.list<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Ch\u1ea1y c\u1eadp nh\u1eadt b\u1eb1ng l\u1ec7nh sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">$ sudo apt-get update<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">C\u00e0i \u0111\u1eb7t b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng l\u1ec7nh sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">$ sudo apt-get install elasticsearch<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ea3i xu\u1ed1ng v\u00e0 c\u00e0i \u0111\u1eb7t g\u00f3i Debian theo c\u00e1ch th\u1ee7 c\u00f4ng b\u1eb1ng l\u1ec7nh sau:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">wget https:\/\/artifacts.elastic.co\/downloads\/elasticsearch\/elasticsearch-8.11.1-amd64.deb<\/span>\n\n<span style=\"font-weight: 400;\">sudo dpkg -i elasticsearch-8.11.1-amd64.deb<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng ti\u1ec7n \u00edch YUM cho h\u1ec7 \u0111i\u1ec1u h\u00e0nh Debian Linux: T\u1ea3i xu\u1ed1ng v\u00e0 c\u00e0i \u0111\u1eb7t Public Signing Key:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">rpm --import https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Th\u00eam v\u0103n b\u1ea3n sau v\u00e0o t\u1ec7p c\u00f3 h\u1eadu t\u1ed1 <\/span><span style=\"font-weight: 400;\">.repo<\/span><span style=\"font-weight: 400;\"> trong th\u01b0 m\u1ee5c <\/span><span style=\"font-weight: 400;\">\u201c\/etc\/yum.repos.d\/\u201d<\/span><span style=\"font-weight: 400;\"> c\u1ee7a b\u1ea1n. V\u00ed d\u1ee5: <\/span><span style=\"font-weight: 400;\">elasticsearch.repo<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">[elasticsearch-8.x]<\/span>\n\n<span style=\"font-weight: 400;\">name=Elasticsearch repository for 8.x packages<\/span>\n\n<span style=\"font-weight: 400;\">baseurl=https:\/\/artifacts.elastic.co\/packages\/8.x\/yum<\/span>\n\n<span style=\"font-weight: 400;\">gpgcheck=1<\/span>\n\n<span style=\"font-weight: 400;\">gpgkey=https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch<\/span>\n\n<span style=\"font-weight: 400;\">enabled=1<\/span>\n\n<span style=\"font-weight: 400;\">autorefresh=1<\/span>\n\n<span style=\"font-weight: 400;\">type=rpm-md<\/span><\/pre>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">B\u00e2y gi\u1edd b\u1ea1n c\u00f3 th\u1ec3 c\u00e0i \u0111\u1eb7t Elasticsearch b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng l\u1ec7nh sau:<\/span><\/li>\n<\/ul>\n<pre><span style=\"font-weight: 400;\">sudo yum install elasticsearch<\/span><\/pre>\n<h3><b>B\u01b0\u1edbc 4: Ch\u1ea1y Elasticsearch Tr\u00ean Windows\/UNIX<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110i \u0111\u1ebfn th\u01b0 m\u1ee5c g\u1ed1c c\u1ee7a Elasticsearch v\u00e0 b\u00ean trong bin folder. Ch\u1ea1y t\u1ec7p <\/span><span style=\"font-weight: 400;\">elasticsearch.bat <\/span><span style=\"font-weight: 400;\">trong tr\u01b0\u1eddng h\u1ee3p Windows ho\u1eb7c b\u1ea1n c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n t\u01b0\u01a1ng t\u1ef1 b\u1eb1ng command prompt v\u00e0 th\u00f4ng qua terminal trong tr\u01b0\u1eddng h\u1ee3p t\u1ec7p UNIX rum Elasticsearch.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Trong Windows:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">cd elasticsearch-8.11.1\\bin<\/span>\n\n<span style=\"font-weight: 400;\">elasticsearch.bat<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong Linux:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">cd elasticsearch-8.11.1\/bin<\/span>\n\n<span style=\"font-weight: 400;\">.\/elasticsearch<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong Linux (n\u1ebfu c\u00e0i \u0111\u1eb7t t\u1eeb package):<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">sudo systemctl start elasticsearch<\/span>\n\n<span style=\"font-weight: 400;\">sudo systemctl enable elasticsearch<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">L\u01b0u \u00fd: Trong tr\u01b0\u1eddng h\u1ee3p s\u1eed d\u1ee5ng Windows, b\u1ea1n c\u00f3 th\u1ec3 g\u1eb7p l\u1ed7i cho bi\u1ebft JAVA_HOME ch\u01b0a \u0111\u01b0\u1ee3c thi\u1ebft l\u1eadp, h\u00e3y c\u00e0i \u0111\u1eb7t Java 17 (cho ES 8.x) v\u00e0 \u0111\u1eb7t bi\u1ebfn m\u00f4i tr\u01b0\u1eddng JAVA_HOME. T\u1eeb Elasticsearch 7.x tr\u1edf \u0111i, ES \u0111\u00e3 \u0111i k\u00e8m v\u1edbi OpenJDK n\u00ean th\u00f4ng th\u01b0\u1eddng kh\u00f4ng c\u1ea7n c\u00e0i \u0111\u1eb7t Java ri\u00eang.<\/span><\/p>\n<h3><b>B\u01b0\u1edbc 5: Ki\u1ec3m tra tr\u1ea1ng th\u00e1i Elasticsearch<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u1ed5ng m\u1eb7c \u0111\u1ecbnh cho giao di\u1ec7n web Elasticsearch l\u00e0 9200 ho\u1eb7c b\u1ea1n c\u00f3 th\u1ec3 thay \u0111\u1ed5i b\u1eb1ng c\u00e1ch thay http.port b\u00ean trong t\u1ec7p elasticsearch.yml c\u00f3 trong bin folder. B\u1ea1n c\u00f3 th\u1ec3 ki\u1ec3m tra xem m\u00e1y ch\u1ee7 c\u00f3 ho\u1ea1t \u0111\u1ed9ng kh\u00f4ng b\u1eb1ng c\u00e1ch duy\u1ec7t <\/span><span style=\"font-weight: 400;\">http:\/\/localhost:9200<\/span><span style=\"font-weight: 400;\">. K\u1ebft qu\u1ea3 s\u1ebd tr\u1ea3 v\u1ec1 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng JSON, ch\u1ee9a th\u00f4ng tin v\u1ec1 Elasticsearch \u0111\u00e3 c\u00e0i \u0111\u1eb7t theo c\u00e1ch sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\"name\" : \"Brain-Child\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\"cluster_name\" : \"elasticsearch\", \"version\" : {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"number\" : \"2.1.0\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"build_hash\" : \"72cd1f1a3eee09505e036106146dc1949dc5dc87\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"build_timestamp\" : \"2015-11-18T22:40:03Z\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"build_snapshot\" : false,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"lucene_version\" : \"5.3.1\"<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0},<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\"tagline\" : \"You Know, for Search\"<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><b>L\u01b0u \u00fd: <\/b><span style=\"font-weight: 400;\">T\u1eeb phi\u00ean b\u1ea3n 8.x, b\u1ea3o m\u1eadt \u0111\u01b0\u1ee3c b\u1eadt m\u1eb7c \u0111\u1ecbnh, n\u00ean c\u1ea7n th\u00eam th\u00f4ng tin x\u00e1c th\u1ef1c:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl -u elastic:password <\/span><span style=\"font-weight: 400;\">http:\/\/localhost:9200<\/span><\/pre>\n<h3><b>B\u01b0\u1edbc 6: C\u00e0i \u0111\u1eb7t Kibana<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong b\u01b0\u1edbc n\u00e0y, ch\u00fang ta s\u1ebd c\u00e0i \u0111\u1eb7t Kibana. Th\u1ef1c hi\u1ec7n theo m\u00e3 t\u01b0\u01a1ng \u1ee9ng \u0111\u01b0\u1ee3c \u0111\u01b0a ra b\u00ean d\u01b0\u1edbi \u0111\u1ec3 c\u00e0i \u0111\u1eb7t tr\u00ean Linux v\u00e0 Windows:<\/span><\/p>\n<h4><span style=\"font-weight: 400;\"><strong>C\u00e0i \u0111\u1eb7t tr\u00ean Linux<\/strong><\/span><\/h4>\n<pre><span style=\"font-weight: 400;\">wget https:\/\/artifacts.elastic.co\/downloads\/kibana\/kibana-8.11.1-linux-x86_64.tar.gz<\/span>\n\n<span style=\"font-weight: 400;\">tar -xzf kibana-8.11.1-linux-x86_64.tar.gz<\/span>\n\n<span style=\"font-weight: 400;\">cd kibana-8.11.1-linux-x86_64\/<\/span>\n\n<span style=\"font-weight: 400;\">.\/bin\/kibana<\/span><\/pre>\n<h4><strong>C\u00e0i \u0111\u1eb7t tr\u00ean Windows<\/strong><\/h4>\n<p><span style=\"font-weight: 400;\">T\u1ea3i xu\u1ed1ng Kibana cho Windows t\u1eeb <\/span><a href=\"https:\/\/www.elastic.co\/downloads\/kibana\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">https:\/\/www.elastic.co\/downloads\/kibana<\/span><\/a><span style=\"font-weight: 400;\">. Khi b\u1ea1n nh\u1ea5p v\u00e0o li\u00ean k\u1ebft, trang ch\u1ee7 s\u1ebd \u0111\u01b0\u1ee3c hi\u1ec3n th\u1ecb. B\u1ea1n gi\u1ea3i n\u00e9n v\u00e0 chuy\u1ec3n \u0111\u1ebfn th\u01b0 m\u1ee5c g\u1ed1c c\u1ee7a Kibana r\u1ed3i ch\u1ea1y n\u00f3:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">cd c:\\kibana-8.11.1-windows-x86_64\u00a0<\/span>\n\n<span style=\"font-weight: 400;\">.\\bin\\kibana.bat<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">C\u1ea5u h\u00ecnh c\u01a1 b\u1ea3n Kibana (kibana.yml):<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">elasticsearch.hosts: [\"http:\/\/localhost:9200\"]<\/span>\n\n<span style=\"font-weight: 400;\">elasticsearch.username: \"kibana_system\"<\/span>\n\n<span style=\"font-weight: 400;\">elasticsearch.password: \"password\"<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Elasticsearch_tutorial_Cach_lap_chi_muc_va_truy_van_du_lieu_trong_Elasticsearch\"><\/span><b>Elasticsearch tutorial: C\u00e1ch l\u1eadp ch\u1ec9 m\u1ee5c v\u00e0 truy v\u1ea5n d\u1eef li\u1ec7u trong Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Sau khi thi\u1ebft l\u1eadp Elasticsearch xong, b\u1ea1n c\u00f3 th\u1ec3 b\u1eaft \u0111\u1ea7u l\u1eadp ch\u1ec9 m\u1ee5c d\u1eef li\u1ec7u b\u1eb1ng RESTful API ho\u1eb7c m\u1ed9t trong c\u00e1c tr\u00ecnh Elasticsearch clients c\u00f3 s\u1eb5n cho nhi\u1ec1u ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh kh\u00e1c nhau nh\u01b0 Python, Java ho\u1eb7c JavaScript.<\/span><\/p>\n<h3><b>S\u1eed d\u1ee5ng RESTful API<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 l\u1eadp ch\u1ec9 m\u1ee5c m\u1ed9t t\u00e0i li\u1ec7u b\u1eb1ng RESTful API , b\u1ea1n g\u1eedi y\u00eau c\u1ea7u PUT ho\u1eb7c POST \u0111\u1ebfn m\u00e1y ch\u1ee7 Elasticsearch v\u1edbi d\u1eef li\u1ec7u t\u00e0i li\u1ec7u \u1edf \u0111\u1ecbnh d\u1ea1ng JSON.\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">H\u00e3y c\u00f9ng xem qua m\u1ed9t v\u00ed d\u1ee5 s\u1eed d\u1ee5ng l\u1ec7nh curl:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl -XPOST \"localhost:9200\/products\/_doc\/1\" -H 'Content-Type: application\/json' -d'<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"name\": \"iPhone 13\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"description\": \"The latest iPhone model with advanced features\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"price\": 999<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Trong v\u00ed d\u1ee5 n\u00e0y:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">localhost:9200<\/span><span style=\"font-weight: 400;\"> l\u00e0 \u0111\u1ecba ch\u1ec9 m\u00e1y ch\u1ee7 Elasticsearch c\u1ee7a b\u1ea1n.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">products<\/span><span style=\"font-weight: 400;\"> l\u00e0 t\u00ean c\u1ee7a ch\u1ec9 m\u1ee5c m\u00e0 ch\u00fang ta mu\u1ed1n l\u01b0u tr\u1eef t\u00e0i li\u1ec7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">_doc<\/span><span style=\"font-weight: 400;\"> l\u00e0 ki\u1ec3u t\u00e0i li\u1ec7u (l\u01b0u \u00fd r\u1eb1ng trong c\u00e1c phi\u00ean b\u1ea3n g\u1ea7n \u0111\u00e2y c\u1ee7a Elasticsearch, type \u0111\u00e3 kh\u00f4ng c\u00f2n \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng n\u1eefa v\u00e0 _doc \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng l\u00e0m m\u1eb7c \u0111\u1ecbnh).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">1 l\u00e0 ID c\u1ee7a t\u00e0i li\u1ec7u. N\u1ebfu b\u1ea1n kh\u00f4ng ch\u1ec9 \u0111\u1ecbnh ID, Elasticsearch s\u1ebd t\u1ea1o m\u1ed9t ID cho b\u1ea1n.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Output: N\u1ebfu t\u00e0i li\u1ec7u \u0111\u01b0\u1ee3c l\u1eadp ch\u1ec9 m\u1ee5c th\u00e0nh c\u00f4ng, b\u1ea1n s\u1ebd nh\u1eadn \u0111\u01b0\u1ee3c ph\u1ea3n h\u1ed3i t\u1eeb Elasticsearch cho bi\u1ebft \u0111i\u1ec1u \u0111\u00f3. Ph\u1ea3n h\u1ed3i bao g\u1ed3m t\u00ean ch\u1ec9 m\u1ee5c, lo\u1ea1i t\u00e0i li\u1ec7u v\u00e0 ID. V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_index\": \"products\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_type\": \"_doc\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_id\": \"1\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_version\": 1,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"result\": \"created\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_shards\": {<\/span>\n\n<span style=\"font-weight: 400;\">\"total\": 2,<\/span>\n\n<span style=\"font-weight: 400;\">\"successful\": 1,<\/span>\n\n<span style=\"font-weight: 400;\">\"failed\": 0<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0},<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_seq_no\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_primary_term\": 1<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h3><b>S\u1eed d\u1ee5ng Elasticsearch clients<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong khi RESTful API h\u1eefu \u00edch cho vi\u1ec7c ki\u1ec3m tra th\u1ee7 c\u00f4ng v\u00e0 c\u00e1c t\u00e1c v\u1ee5 \u0111\u01a1n gi\u1ea3n, vi\u1ec7c s\u1eed d\u1ee5ng Elasticsearch client trong ng\u00f4n ng\u1eef l\u1eadp tr\u00ecnh \u01b0a th\u00edch c\u1ee7a b\u1ea1n mang l\u1ea1i s\u1ef1 linh ho\u1ea1t v\u00e0 ti\u1ec7n l\u1ee3i h\u01a1n, \u0111\u1eb7c bi\u1ec7t l\u00e0 \u0111\u1ed1i v\u1edbi c\u00e1c t\u00e1c v\u1ee5 l\u1eadp ch\u1ec9 m\u1ee5c ph\u1ee9c t\u1ea1p.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 v\u1ec1 vi\u1ec7c l\u1eadp ch\u1ec9 m\u1ee5c t\u00e0i li\u1ec7u b\u1eb1ng Elasticsearch Python client:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\"># Connect to Elasticsearch server<\/span>\n<span style=\"font-weight: 400;\">es = Elasticsearch(['localhost:9200'])<\/span>\n\n<span style=\"font-weight: 400;\"># Index a document<\/span>\n<span style=\"font-weight: 400;\">doc = {<\/span>\n<span style=\"font-weight: 400;\">\"name\": \"Samsung Galaxy S21\",<\/span>\n<span style=\"font-weight: 400;\">\"description\": \"Flagship smartphone with stunning display and camera\",<\/span>\n<span style=\"font-weight: 400;\">\"price\": 799<\/span>\n<span style=\"font-weight: 400;\">}<\/span>\n<span style=\"font-weight: 400;\">res = es.index(index=\"products\", doc_type=\"_doc\", id=2, body=doc)<\/span>\n<span style=\"font-weight: 400;\">print(res)<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Output: Output s\u1ebd t\u01b0\u01a1ng t\u1ef1 nh\u01b0 ph\u1ea3n h\u1ed3i c\u1ee7a RESTful API , x\u00e1c nh\u1eadn vi\u1ec7c l\u1eadp ch\u1ec9 m\u1ee5c t\u00e0i li\u1ec7u th\u00e0nh c\u00f4ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 \u0111\u1ea3m b\u1ea3o l\u1eadp ch\u1ec9 m\u1ee5c v\u00e0 truy v\u1ea5n hi\u1ec7u qu\u1ea3 trong Elasticsearch, c\u1ea7n ph\u1ea3i tu\u00e2n theo c\u00e1c bi\u1ec7n ph\u00e1p t\u1ed1t nh\u1ea5t:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">L\u1eadp ch\u1ec9 m\u1ee5c h\u00e0ng lo\u1ea1t: S\u1eed d\u1ee5ng API h\u00e0ng lo\u1ea1t c\u1ee7a Elasticsearch \u0111\u1ec3 l\u1eadp ch\u1ec9 m\u1ee5c c\u00e1c t\u1eadp d\u1eef li\u1ec7u l\u1edbn.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ed1i \u01b0u h\u00f3a \u00e1nh x\u1ea1: Thi\u1ebft k\u1ebf \u00e1nh x\u1ea1 ph\u1ea3n \u00e1nh ch\u00ednh x\u00e1c c\u1ea5u tr\u00fac d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n v\u00e0 t\u1ed1i \u01b0u h\u00f3a hi\u1ec7u su\u1ea5t t\u00ecm ki\u1ebfm.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ph\u00e2n chia v\u00e0 sao ch\u00e9p ch\u1ec9 m\u1ee5c: C\u1ea5u h\u00ecnh c\u00e1c thi\u1ebft l\u1eadp nh\u01b0 ph\u00e2n chia v\u00e0 sao ch\u00e9p \u0111\u1ec3 qu\u1ea3n l\u00fd ph\u00e2n ph\u1ed1i d\u1eef li\u1ec7u v\u00e0 d\u1ef1 ph\u00f2ng hi\u1ec7u qu\u1ea3.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Theo d\u00f5i t\u00ecnh tr\u1ea1ng ch\u1ec9 m\u1ee5c: Th\u01b0\u1eddng xuy\u00ean theo d\u00f5i t\u00ecnh tr\u1ea1ng v\u00e0 hi\u1ec7u su\u1ea5t c\u1ee7a ch\u1ec9 m\u1ee5c b\u1eb1ng c\u00e1c c\u00f4ng c\u1ee5 gi\u00e1m s\u00e1t Elasticsearch \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh v\u00e0 gi\u1ea3i quy\u1ebft k\u1ecbp th\u1eddi m\u1ecdi s\u1ef1 c\u1ed1.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Elasticsearch_tutorial_Cach_tim_kiem_du_lieu_co_ban_trong_Elasticsearch\"><\/span><b>Elasticsearch tutorial: C\u00e1ch t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u c\u01a1 b\u1ea3n trong Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">H\u00e3y b\u1eaft \u0111\u1ea7u b\u1eb1ng c\u00e1ch kh\u00e1m ph\u00e1 m\u1ed9t s\u1ed1 truy v\u1ea5n t\u00ecm ki\u1ebfm (query) c\u01a1 b\u1ea3n m\u00e0 b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng \u0111\u1ec3 t\u00ecm ki\u1ebfm t\u00e0i li\u1ec7u trong Elasticsearch.<\/span><\/p>\n<h3><b>Match Query<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Match Query l\u00e0 m\u1ed9t trong nh\u1eefng truy v\u1ea5n \u0111\u01a1n gi\u1ea3n v\u00e0 ph\u1ed5 bi\u1ebfn nh\u1ea5t trong Elasticsearch. Truy v\u1ea5n n\u00e0y cho ph\u00e9p b\u1ea1n t\u00ecm ki\u1ebfm c\u00e1c t\u00e0i li\u1ec7u c\u00f3 ch\u1ee9a m\u1ed9t thu\u1eadt ng\u1eef ho\u1eb7c c\u1ee5m t\u1eeb c\u1ee5 th\u1ec3. V\u00ed d\u1ee5 d\u01b0\u1edbi \u0111\u00e2y t\u00ecm ki\u1ebfm t\u00e0i li\u1ec7u trong ch\u1ec9 m\u1ee5c s\u1ea3n ph\u1ea9m c\u00f3 name field ch\u1ee9a thu\u1eadt ng\u1eef &#8220;iphone&#8221;. Elasticsearch s\u1ebd tr\u1ea3 v\u1ec1 t\u1ea5t c\u1ea3 c\u00e1c t\u00e0i li\u1ec7u ph\u00f9 h\u1ee3p v\u1edbi ti\u00eau ch\u00ed n\u00e0y c\u00f9ng v\u1edbi th\u00f4ng tin c\u00f3 li\u00ean quan.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/products\/_search<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\"match\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\"name\": \"iphone\"<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h3><b>Term Query<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Term query \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 match ch\u00ednh x\u00e1c c\u00e1c thu\u1eadt ng\u1eef, h\u1eefu \u00edch khi b\u1ea1n mu\u1ed1n t\u00ecm c\u00e1c t\u00e0i li\u1ec7u ch\u1ee9a gi\u00e1 tr\u1ecb ch\u00ednh x\u00e1c trong m\u1ed9t tr\u01b0\u1eddng c\u1ee5 th\u1ec3. V\u00ed d\u1ee5 d\u01b0\u1edbi \u0111\u00e2y t\u00ecm ki\u1ebfm c\u00e1c t\u00e0i li\u1ec7u trong ch\u1ec9 m\u1ee5c s\u1ea3n ph\u1ea9m c\u00f3 category field kh\u1edbp ch\u00ednh x\u00e1c v\u1edbi &#8220;electronics&#8221;.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/products\/_search<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\"term\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\"category\": \"electronics\"<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Elasticsearch_tutorial_Cach_tim_kiem_nang_cao_trong_Elasticsearch\"><\/span><b>Elasticsearch tutorial: C\u00e1ch t\u00ecm ki\u1ebfm n\u00e2ng cao trong Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Ngo\u00e0i c\u00e1c truy v\u1ea5n c\u01a1 b\u1ea3n, Elasticsearch c\u00f2n cung c\u1ea5p nhi\u1ec1u k\u1ef9 thu\u1eadt t\u00ecm ki\u1ebfm n\u00e2ng cao \u0111\u1ec3 gi\u00fap b\u1ea1n tinh ch\u1ec9nh t\u00ecm ki\u1ebfm v\u00e0 t\u00ecm ra nh\u1eefng t\u00e0i li\u1ec7u c\u00f3 li\u00ean quan nh\u1ea5t.<\/span><\/p>\n<h3><b>Fuzzy Query<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Fuzzy query \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 t\u00ecm c\u00e1c t\u00e0i li\u1ec7u c\u00f3 ch\u1ee9a c\u00e1c thu\u1eadt ng\u1eef t\u01b0\u01a1ng t\u1ef1 v\u1edbi m\u1ed9t thu\u1eadt ng\u1eef \u0111\u00e3 ch\u1ec9 \u0111\u1ecbnh. Truy v\u1ea5n n\u00e0y h\u1eefu \u00edch khi x\u1eed l\u00fd l\u1ed7i \u0111\u00e1nh m\u00e1y ho\u1eb7c c\u00e1c bi\u1ebfn th\u1ec3 v\u1ec1 ch\u00ednh t\u1ea3. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 v\u00ed d\u1ee5 t\u00ecm ki\u1ebfm c\u00e1c t\u00e0i li\u1ec7u trong \u0111\u00f3 name field ch\u1ee9a c\u00e1c thu\u1eadt ng\u1eef t\u01b0\u01a1ng t\u1ef1 nh\u01b0 &#8220;iphon&#8221; (v\u00ed d\u1ee5: &#8220;iPhone&#8221;).<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/products\/_search<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\"fuzzy\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\"name\": \"iphon\"<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h3><b>Range Query<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Range query cho ph\u00e9p b\u1ea1n t\u00ecm ki\u1ebfm t\u00e0i li\u1ec7u trong ph\u1ea1m vi gi\u00e1 tr\u1ecb \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh. Truy v\u1ea5n n\u00e0y th\u01b0\u1eddng \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng khi x\u1eed l\u00fd c\u00e1c tr\u01b0\u1eddng s\u1ed1 ho\u1eb7c ng\u00e0y th\u00e1ng. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 v\u00ed d\u1ee5 t\u00ecm ki\u1ebfm c\u00e1c t\u00e0i li\u1ec7u c\u00f3 gi\u00e1 n\u1eb1m trong kho\u1ea3ng t\u1eeb 500 \u0111\u1ebfn 1000.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/products\/_search<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\"range\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\"price\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\"gte\": 500,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\"lte\": 1000<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Elasticsearch_tutorial_Cach_ket_hop_cac_truy_van_trong_Elasticsearch\"><\/span><b>Elasticsearch tutorial: C\u00e1ch k\u1ebft h\u1ee3p c\u00e1c truy v\u1ea5n trong Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Elasticsearch cho ph\u00e9p b\u1ea1n k\u1ebft h\u1ee3p nhi\u1ec1u truy v\u1ea5n b\u1eb1ng logic boolean \u0111\u1ec3 t\u1ea1o ra ti\u00eau ch\u00ed t\u00ecm ki\u1ebfm ph\u1ee9c t\u1ea1p h\u01a1n.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Bool query \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 k\u1ebft h\u1ee3p nhi\u1ec1u truy v\u1ea5n b\u1eb1ng c\u00e1c boolean operator nh\u01b0 must, should, must_not v\u00e0 filter. V\u00ed d\u1ee5 d\u01b0\u1edbi \u0111\u00e2y s\u1eed d\u1ee5ng bool query \u0111\u1ec3 t\u00ecm c\u00e1c t\u00e0i li\u1ec7u c\u00f3 name field ch\u1ee9a &#8220;iphone&#8221; v\u00e0 category l\u00e0 &#8220;electronics&#8221;. Elasticsearch s\u1ebd tr\u1ea3 v\u1ec1 c\u00e1c t\u00e0i li\u1ec7u \u0111\u00e1p \u1ee9ng c\u1ea3 hai \u0111i\u1ec1u ki\u1ec7n.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/products\/_search<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\"bool\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">\"must\": [<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">{ \"match\": { \"name\": \"iphone\" } },<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">{ \"term\": { \"category\": \"electronics\" } }<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0<\/span> <span style=\"font-weight: 400;\">]<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0}<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Elasticsearch_tutorial_Cach_giam_sat_va_toi_uu_hoa_trong_Elasticsearch\"><\/span><b>Elasticsearch tutorial: C\u00e1ch gi\u00e1m s\u00e1t v\u00e0 t\u1ed1i \u01b0u h\u00f3a trong Elasticsearch<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Vi\u1ec7c theo d\u00f5i t\u00ecnh tr\u1ea1ng c\u1ee7a cluster li\u00ean quan \u0111\u1ebfn vi\u1ec7c s\u1eed d\u1ee5ng c\u00e1c API c\u1ee5 th\u1ec3 v\u00e0 hi\u1ec3u c\u00e1c s\u1ed1 li\u1ec7u ch\u00ednh \u0111\u1ec3 x\u00e1c \u0111\u1ecbnh v\u00e0 gi\u1ea3i quy\u1ebft v\u1ea5n \u0111\u1ec1 k\u1ecbp th\u1eddi. Th\u00f4ng tin d\u01b0\u1edbi \u0111\u00e2y cung c\u1ea5p c\u00e1i nh\u00ecn s\u00e2u s\u1eafc v\u1ec1 vi\u1ec7c s\u1eed d\u1ee5ng API Cluster Health, di\u1ec5n gi\u1ea3i c\u00e1c s\u1ed1 li\u1ec7u v\u1ec1 t\u00ecnh tr\u1ea1ng v\u00e0 x\u00e1c \u0111\u1ecbnh c\u00e1c v\u1ea5n \u0111\u1ec1 chung v\u1ec1 t\u00ecnh tr\u1ea1ng c\u1ee7a cluster.\u00a0<\/span><\/p>\n<h3><b>C\u00e1ch s\u1eed d\u1ee5ng Cluster Health API\u00a0<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Cluster Health API trong Elasticsearch cung c\u1ea5p t\u1ed5ng quan to\u00e0n di\u1ec7n v\u1ec1 t\u00ecnh tr\u1ea1ng c\u1ee7a cluster, th\u00f4ng tin chi ti\u1ebft quan tr\u1ecdng v\u1ec1 tr\u1ea1ng th\u00e1i hi\u1ec7n t\u1ea1i c\u1ee7a cluster. \u0110\u00e2y l\u00e0 c\u00f4ng c\u1ee5 quan tr\u1ecdng d\u00e0nh cho qu\u1ea3n tr\u1ecb vi\u00ean \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o cluster ho\u1ea1t \u0111\u1ed9ng tr\u01a1n tru. \u0110\u1ec3 truy c\u1eadp Cluster Health API, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng endpoint sau \u0111\u00e2y:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">GET \/_cluster\/health<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">API call n\u00e0y n\u00e0y tr\u1ea3 v\u1ec1 m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng JSON ch\u1ee9a m\u1ed9t s\u1ed1 tr\u01b0\u1eddng quan tr\u1ecdng m\u00f4 t\u1ea3 tr\u1ea1ng th\u00e1i c\u1ee7a cluster. Sau \u0111\u00e2y l\u00e0 m\u1ed9t v\u00ed d\u1ee5 v\u1ec1 ph\u1ea3n h\u1ed3i.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"cluster_name\": \"my_cluster\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"status\": \"yellow\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"timed_out\": false,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"number_of_nodes\": 3,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"number_of_data_nodes\": 2,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"active_primary_shards\": 5,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"active_shards\": 10,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"relocating_shards\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"initializing_shards\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"unassigned_shards\": 2,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"delayed_unassigned_shards\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"number_of_pending_tasks\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"number_of_in_flight_fetch\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"task_max_waiting_in_queue_millis\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"active_shards_percent_as_number\": 83.3<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h3><b>\u00dd ngh\u0129a s\u1ed1 li\u1ec7u do Cluster Health API cung c\u1ea5p<\/b><\/h3>\n<h4><b>Tr\u1ea1ng th\u00e1i cluster<\/b><\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u00e0u xanh l\u00e1 c\u00e2y: T\u1ea5t c\u1ea3 c\u00e1c primary shard v\u00e0 replica \u0111\u1ec1u \u0111ang ho\u1ea1t \u0111\u1ed9ng v\u00e0 \u0111\u01b0\u1ee3c ph\u00e2n b\u1ed5. Cluster \u0111ang ho\u1ea1t \u0111\u1ed9ng \u0111\u1ea7y \u0111\u1ee7.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">V\u00e0ng: T\u1ea5t c\u1ea3 c\u00e1c primary shard \u0111\u1ec1u ho\u1ea1t \u0111\u1ed9ng, nh\u01b0ng m\u1ed9t s\u1ed1 replica ch\u01b0a \u0111\u01b0\u1ee3c ph\u00e2n b\u1ed5. Cluster \u0111ang ho\u1ea1t \u0111\u1ed9ng, nh\u01b0ng t\u00ednh d\u1ef1 ph\u00f2ng b\u1ecb x\u00e2m ph\u1ea1m.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110\u1ecf: M\u1ed9t s\u1ed1 primary shard ch\u01b0a \u0111\u01b0\u1ee3c ph\u00e2n b\u1ed5. D\u1eef li\u1ec7u b\u1ecb thi\u1ebfu ho\u1eb7c kh\u00f4ng kh\u1ea3 d\u1ee5ng v\u00e0 cluster kh\u00f4ng ho\u1ea1t \u0111\u1ed9ng \u0111\u1ea7y \u0111\u1ee7.<\/span><\/li>\n<\/ul>\n<h4><b>S\u1ed1 l\u01b0\u1ee3ng n\u00fat<\/b><\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">number_of_nodes: T\u1ed5ng s\u1ed1 node trong cluster. S\u1ed1 n\u00e0y ph\u1ea3i kh\u1edbp v\u1edbi s\u1ed1 l\u01b0\u1ee3ng node d\u1ef1 ki\u1ebfn.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">number_of_data_nodes: S\u1ed1 l\u01b0\u1ee3ng node \u0111\u01b0\u1ee3c ch\u1ec9 \u0111\u1ecbnh \u0111\u1ec3 l\u01b0u tr\u1eef d\u1eef li\u1ec7u.<\/span><\/li>\n<\/ul>\n<h4><b>Th\u1ed1ng k\u00ea Shard<\/b><\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">active_primary_shards: S\u1ed1 l\u01b0\u1ee3ng primary shard \u0111ang ho\u1ea1t \u0111\u1ed9ng. S\u1ed1 n\u00e0y ph\u1ea3i b\u1eb1ng t\u1ed5ng s\u1ed1 primary shard tr\u00ean t\u1ea5t c\u1ea3 c\u00e1c ch\u1ec9 m\u1ee5c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">active_shards: T\u1ed5ng s\u1ed1 shard \u0111ang ho\u1ea1t \u0111\u1ed9ng (ch\u00ednh v\u00e0 b\u1ea3n sao).<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">relocating_shards: C\u00e1c primary shard \u0111ang trong qu\u00e1 tr\u00ecnh di chuy\u1ec3n t\u1eeb node n\u00e0y sang node kh\u00e1c. S\u1ed1 l\u01b0\u1ee3ng l\u1edbn \u1edf \u0111\u00e2y c\u00f3 th\u1ec3 ch\u1ec9 ra qu\u00e1 tr\u00ecnh c\u00e2n b\u1eb1ng \u0111ang di\u1ec5n ra.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">initializing_shards: C\u00e1c shard \u0111ang \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o. Con s\u1ed1 cao li\u00ean t\u1ee5c c\u00f3 th\u1ec3 ch\u1ec9 ra s\u1ef1 c\u1ed1.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">unassigned_shards: C\u00e1c shard kh\u00f4ng \u0111\u01b0\u1ee3c g\u00e1n cho b\u1ea5t k\u1ef3 node n\u00e0o. \u0110\u00e2y l\u00e0 s\u1ed1 li\u1ec7u quan tr\u1ecdng c\u1ea7n theo d\u00f5i v\u00ec c\u00e1c primary shard kh\u00f4ng \u0111\u01b0\u1ee3c g\u00e1n c\u00f3 ngh\u0129a l\u00e0 d\u1eef li\u1ec7u kh\u00f4ng kh\u1ea3 d\u1ee5ng.<\/span><\/li>\n<\/ul>\n<h4><b>Th\u1ed1ng k\u00ea nhi\u1ec7m v\u1ee5<\/b><\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">number_of_pending_tasks: C\u00e1c t\u00e1c v\u1ee5 \u0111ang ch\u1edd x\u1eed l\u00fd. S\u1ed1 l\u01b0\u1ee3ng t\u00e1c v\u1ee5 \u0111ang ch\u1edd x\u1eed l\u00fd cao c\u00f3 th\u1ec3 ch\u1ec9 ra t\u00ecnh tr\u1ea1ng t\u1eafc ngh\u1ebdn.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">task_max_waiting_in_queue_millis: Th\u1eddi gian ch\u1edd t\u1ed1i \u0111a c\u1ee7a m\u1ed9t t\u00e1c v\u1ee5 trong h\u00e0ng \u0111\u1ee3i. Th\u1eddi gian ch\u1edd d\u00e0i c\u00f3 th\u1ec3 b\u00e1o hi\u1ec7u c\u00e1c v\u1ea5n \u0111\u1ec1 v\u1ec1 hi\u1ec7u su\u1ea5t.<\/span><\/li>\n<\/ul>\n<h4><b>T\u1ef7 l\u1ec7 ph\u00e2n b\u1ed5 shard<\/b><\/h4>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">active_shards_percent_as_number: T\u1ef7 l\u1ec7 ph\u1ea7n tr\u0103m c\u00e1c shard \u0111ang ho\u1ea1t \u0111\u1ed9ng so v\u1edbi t\u1ed5ng s\u1ed1 c\u00e1c shard, l\u00fd t\u01b0\u1edfng nh\u1ea5t l\u00e0 g\u1ea7n 100%.<\/span><\/li>\n<\/ul>\n<h3><b>T\u1ed1i \u01b0u h\u00f3a Shards v\u00e0 Replicas<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Hi\u1ec7u su\u1ea5t c\u1ee7a Elasticsearch cluster ph\u1ee5 thu\u1ed9c r\u1ea5t nhi\u1ec1u v\u00e0o m\u1ee9c \u0111\u1ed9 c\u1ea5u h\u00ecnh c\u00e1c ph\u00e2n \u0111o\u1ea1n v\u00e0 b\u1ea3n sao. C\u00e1c v\u1ea5n \u0111\u1ec1 c\u1ea7n c\u00e2n nh\u1eafc bao g\u1ed3m:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">K\u00edch th\u01b0\u1edbc shard: K\u00edch th\u01b0\u1edbc shard t\u1ed1i \u01b0u th\u01b0\u1eddng n\u1eb1m trong kho\u1ea3ng t\u1eeb 20GB \u0111\u1ebfn 40GB cho d\u1eef li\u1ec7u time-based. Gi\u1eef k\u00edch th\u01b0\u1edbc shard trong ph\u1ea1m vi n\u00e0y \u0111\u1ea3m b\u1ea3o hi\u1ec7u su\u1ea5t truy v\u1ea5n hi\u1ec7u qu\u1ea3 v\u00e0 th\u1eddi gian c\u00e2n b\u1eb1ng l\u1ea1i c\u00f3 th\u1ec3 qu\u1ea3n l\u00fd \u0111\u01b0\u1ee3c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1ed1 l\u01b0\u1ee3ng shard: Tr\u00e1nh c\u00e1c shard qu\u00e1 nhi\u1ec1u \u0111\u1ec3 gi\u1ea3m chi ph\u00ed. M\u1ed9t nguy\u00ean t\u1eafc chung l\u00e0 gi\u1eef s\u1ed1 l\u01b0\u1ee3ng m\u1ea3nh tr\u00ean m\u1ed7i GB heap space d\u01b0\u1edbi 20.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u1ea5u h\u00ecnh replica: \u0110i\u1ec1u ch\u1ec9nh s\u1ed1 l\u01b0\u1ee3ng replica c\u00f3 th\u1ec3 t\u0103ng c\u01b0\u1eddng hi\u1ec7u su\u1ea5t \u0111\u1ecdc v\u00e0 kh\u1ea3 n\u0103ng ph\u1ee5c h\u1ed3i. T\u0103ng s\u1ed1 l\u01b0\u1ee3ng replica c\u1ea3i thi\u1ec7n kh\u1ea3 n\u0103ng ch\u1ecbu l\u1ed7i nh\u01b0ng c\u0169ng \u0111\u00f2i h\u1ecfi nhi\u1ec1u n\u0103ng l\u01b0\u1ee3ng l\u01b0u tr\u1eef v\u00e0 x\u1eed l\u00fd h\u01a1n.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Elasticsearch_tutorial_Cach_kiem_soat_an_ninh_va_truy_cap\"><\/span><b>Elasticsearch tutorial: C\u00e1ch ki\u1ec3m so\u00e1t an ninh v\u00e0 truy c\u1eadp<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>B\u1ea3o m\u1eadt Elasticsearch b\u1eb1ng c\u1ea5u h\u00ecnh m\u00e3 h\u00f3a SSL\/TLS n\u00e2ng cao<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">B\u1ea3o m\u1eadt Elasticsearch l\u00e0 \u0111i\u1ec1u quan tr\u1ecdng \u0111\u1ec3 b\u1ea3o v\u1ec7 d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n v\u00e0 \u0111\u1ea3m b\u1ea3o giao ti\u1ebfp an to\u00e0n trong Elasticsearch cluster v\u00e0 gi\u1eefa c\u00e1c client. M\u1ed9t trong nh\u1eefng c\u00e1ch hi\u1ec7u qu\u1ea3 nh\u1ea5t l\u00e0 c\u1ea5u h\u00ecnh m\u00e3 h\u00f3a SSL\/TLS. SSL (Secure Sockets Layer) v\u00e0 TLS (Transport Layer Security) l\u00e0 c\u00e1c giao th\u1ee9c m\u1eadt m\u00e3 \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf \u0111\u1ec3 cung c\u1ea5p giao ti\u1ebfp an to\u00e0n qua m\u1ea1ng m\u00e1y t\u00ednh. TLS l\u00e0 giao th\u1ee9c k\u1ebf th\u1eeba SSL v\u00e0 an to\u00e0n h\u01a1n.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Trong Elasticsearch, vi\u1ec7c c\u1ea5u h\u00ecnh m\u00e3 h\u00f3a SSL\/TLS gi\u00fap:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u00e3 h\u00f3a d\u1eef li\u1ec7u khi truy\u1ec1n gi\u1eefa c\u00e1c node.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u00e3 h\u00f3a d\u1eef li\u1ec7u khi truy\u1ec1n gi\u1eefa client v\u00e0 node.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110\u1ea3m b\u1ea3o t\u00ednh to\u00e0n v\u1eb9n c\u1ee7a d\u1eef li\u1ec7u v\u00e0 ng\u0103n ch\u1eb7n s\u1ef1 gi\u1ea3 m\u1ea1o.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">X\u00e1c th\u1ef1c c\u00e1c node v\u00e0 client.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u00a0<\/span><span style=\"font-weight: 400;\">Tr\u01b0\u1edbc khi b\u1eaft \u0111\u1ea7u, h\u00e3y \u0111\u1ea3m b\u1ea3o b\u1ea1n c\u00f3 nh\u1eefng \u0111i\u1ec1u sau:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elasticsearch \u0111\u00e3 \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t v\u00e0 \u0111ang ch\u1ea1y.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Hi\u1ec3u bi\u1ebft c\u01a1 b\u1ea3n v\u1ec1 c\u00e1c t\u1ec7p c\u1ea5u h\u00ecnh Elasticsearch .<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">OpenSSL \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t \u0111\u1ec3 t\u1ea1o ch\u1ee9ng ch\u1ec9.<\/span><\/li>\n<\/ul>\n<h4><b>T\u1ea1o ch\u1ee9ng ch\u1ec9<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Elasticsearch y\u00eau c\u1ea7u ch\u1ee9ng ch\u1ec9 cho m\u00e3 h\u00f3a SSL\/TLS. B\u1ea1n c\u00f3 th\u1ec3 t\u1ea1o ch\u1ee9ng ch\u1ec9 n\u00e0y b\u1eb1ng OpenSSL ho\u1eb7c c\u00f4ng c\u1ee5 Elasticsearch Certutil. D\u01b0\u1edbi \u0111\u00e2y l\u00e0 v\u00ed d\u1ee5 s\u1eed d\u1ee5ng c\u00f4ng c\u1ee5 Elasticsearch Certutil:<\/span><\/p>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 1: T\u1ea1o Certificate Authority (CA)<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u0110\u1ea7u ti\u00ean, h\u00e3y t\u1ea1o m\u1ed9t Certificate Authority (CA) s\u1ebd k\u00fd ch\u1ee9ng ch\u1ec9 cho c\u00e1c node c\u1ee7a b\u1ea1n.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">bin\/elasticsearch-certutil ca<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh n\u00e0y s\u1ebd nh\u1eafc b\u1ea1n nh\u1eadp t\u00ean t\u1ec7p cho CA. V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">elastic-stack-ca.p12<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 2: T\u1ea1o Node Certificate<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Ti\u1ebfp theo, t\u1ea1o ch\u1ee9ng ch\u1ec9 cho c\u00e1c Elasticsearch node b\u1eb1ng CA \u0111\u00e3 t\u1ea1o \u1edf b\u01b0\u1edbc tr\u01b0\u1edbc.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">bin\/elasticsearch-certutil cert --ca elastic-stack-ca.p12<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">L\u1ec7nh n\u00e0y s\u1ebd nh\u1eafc b\u1ea1n nh\u1eadp t\u00ean t\u1ec7p cho Node Certificate. V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">elastic-certificates.p12<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 3: Ph\u00e2n ph\u1ed1i ch\u1ee9ng ch\u1ec9<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Ph\u00e2n ph\u1ed1i t\u1ec7p <\/span><span style=\"font-weight: 400;\">elastic-certificates.p12<\/span><span style=\"font-weight: 400;\"> \u0111\u00e3 t\u1ea1o cho t\u1ea5t c\u1ea3 c\u00e1c Elasticsearch node c\u1ee7a b\u1ea1n. T\u1ec7p n\u00e0y ch\u1ee9a c\u00e1c ch\u1ee9ng ch\u1ec9 c\u1ea7n thi\u1ebft \u0111\u1ec3 b\u1eadt SSL\/TLS.<\/span><\/p>\n<h4><b>C\u1ea5u h\u00ecnh Elasticsearch cho SSL\/TLS<\/b><\/h4>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 1: C\u1eadp nh\u1eadt c\u1ea5u h\u00ecnh Elasticsearch<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">M\u1edf t\u1ec7p c\u1ea5u h\u00ecnh elasticsearch.yml tr\u00ean m\u1ed7i node v\u00e0 th\u00eam c\u00e1c thi\u1ebft l\u1eadp sau \u0111\u1ec3 b\u1eadt SSL\/TLS:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">xpack.security.enabled: true<\/span>\n \n<span style=\"font-weight: 400;\">xpack.security.transport.ssl.enabled: true<\/span>\n<span style=\"font-weight: 400;\">xpack.security.transport.ssl.verification_mode: certificate<\/span>\n<span style=\"font-weight: 400;\">xpack.security.transport.ssl.keystore.path: \/path\/to\/elastic-certificates.p12<\/span>\n<span style=\"font-weight: 400;\">xpack.security.transport.ssl.truststore.path: \/path\/to\/elastic-certificates.p12<\/span>\n \n<span style=\"font-weight: 400;\">xpack.security.http.ssl.enabled: true<\/span>\n<span style=\"font-weight: 400;\">xpack.security.http.ssl.keystore.path: \/path\/to\/elastic-certificates.p12<\/span>\n<span style=\"font-weight: 400;\">xpack.security.http.ssl.truststore.path: \/path\/to\/elastic-certificates.p12<\/span>\n<span style=\"font-weight: 400;\">Replace \/path\/to\/elastic-certificates.p12 with the actual path to your certificate file.<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 2: Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Elasticsearch<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Kh\u1edfi \u0111\u1ed9ng l\u1ea1i t\u1eebng n\u00fat Elasticsearch \u0111\u1ec3 \u00e1p d\u1ee5ng c\u1ea5u h\u00ecnh m\u1edbi:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">bin\/elasticsearch<\/span><\/pre>\n<h4><b>X\u00e1c minh c\u1ea5u h\u00ecnh SSL\/TLS<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 x\u00e1c minh r\u1eb1ng SSL\/TLS \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh \u0111\u00fang, b\u1ea1n c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng curl \u0111\u1ec3 g\u1eedi y\u00eau c\u1ea7u HTTPS t\u1edbi c\u1ee5m Elasticsearch c\u1ee7a m\u00ecnh. V\u00ed d\u1ee5<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl --cacert \/path\/to\/elastic-stack-ca.crt -u elastic:password https:\/\/localhost:9200<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">N\u1ebfu SSL\/TLS \u0111\u01b0\u1ee3c c\u1ea5u h\u00ecnh \u0111\u00fang, b\u1ea1n s\u1ebd th\u1ea5y ph\u1ea3n h\u1ed3i t\u1eeb Elasticsearch nh\u01b0 sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"name\" : \"node-1\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"cluster_name\" : \"my-cluster\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"cluster_uuid\" : \"abcd1234\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"version\" : {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"number\" : \"7.10.0\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"build_flavor\" : \"default\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"build_type\" : \"tar\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"build_hash\" : \"abcdefg\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"build_date\" : \"2020-11-10T22:14:56.825533Z\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"build_snapshot\" : false,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"lucene_version\" : \"8.7.0\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"minimum_wire_compatibility_version\" : \"6.8.0\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"minimum_index_compatibility_version\" : \"6.0.0-beta1\"<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0},<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"tagline\" : \"You Know, for Search\"<\/span>\n\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<h4><b>C\u1ea5u h\u00ecnh x\u00e1c th\u1ef1c client<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 b\u1ea3o m\u1eadt Elasticsearch cluster h\u01a1n n\u1eefa, b\u1ea1n c\u00f3 th\u1ec3 c\u1ea5u h\u00ecnh x\u00e1c th\u1ef1c client certificate. \u0110i\u1ec1u n\u00e0y \u0111\u1ea3m b\u1ea3o ch\u1ec9 nh\u1eefng client c\u00f3 ch\u1ee9ng ch\u1ec9 h\u1ee3p l\u1ec7 m\u1edbi c\u00f3 th\u1ec3 truy c\u1eadp cluster.<\/span><\/p>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 1: T\u1ea1o client certificate<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng c\u00f4ng c\u1ee5 Elasticsearch Certutil \u0111\u1ec3 t\u1ea1o client certificate. L\u1ec7nh d\u01b0\u1edbi \u0111\u00e2y s\u1ebd nh\u1eafc b\u1ea1n nh\u1eadp t\u00ean t\u1ec7p cho client certificate. V\u00ed d\u1ee5: client-certificates.p12 .<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">bin\/elasticsearch-certutil cert --ca elastic-stack-ca.p12<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 2: C\u1ea5u h\u00ecnh x\u00e1c th\u1ef1c client<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">M\u1edf t\u1ec7p c\u1ea5u h\u00ecnh elasticsearch.yml v\u00e0 th\u00eam c\u00e1c thi\u1ebft l\u1eadp sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">xpack.security.http.ssl.client_authentication: required<\/span>\n\n<span style=\"font-weight: 400;\">xpack.security.http.ssl.certificate_authorities: [\"\/path\/to\/elastic-stack-ca.crt\"]<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Elasticsearch \u0111\u1ec3 \u00e1p d\u1ee5ng c\u00e1c thay \u0111\u1ed5i:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">bin\/elasticsearch<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 3: S\u1eed d\u1ee5ng client certificate v\u1edbi Curl<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 th\u1ef1c hi\u1ec7n y\u00eau c\u1ea7u x\u00e1c th\u1ef1c b\u1eb1ng client certificate, h\u00e3y s\u1eed d\u1ee5ng l\u1ec7nh curl sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl --cert \/path\/to\/client.crt --key \/path\/to\/client.key --cacert \/path\/to\/elastic-stack-ca.crt https:\/\/localhost:9200<\/span><\/pre>\n<h4><b>\u0110\u1ecbnh c\u1ea5u h\u00ecnh Kibana cho SSL\/TLS<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">N\u1ebfu b\u1ea1n \u0111ang s\u1eed d\u1ee5ng Kibana v\u1edbi Elasticsearch, b\u1ea1n c\u1ea7n c\u1ea5u h\u00ecnh Kibana \u0111\u1ec3 giao ti\u1ebfp v\u1edbi Elasticsearch qua HTTPS.<\/span><\/p>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 1: C\u1eadp nh\u1eadt c\u1ea5u h\u00ecnh Kibana<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">M\u1edf t\u1ec7p c\u1ea5u h\u00ecnh kibana.yml v\u00e0 th\u00eam c\u00e1c thi\u1ebft l\u1eadp sau:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">elasticsearch.hosts: [\"https:\/\/localhost:9200\"]<\/span>\n\n<span style=\"font-weight: 400;\">elasticsearch.ssl.certificateAuthorities: [\"\/path\/to\/elastic-stack-ca.crt\"]<\/span>\n\n<span style=\"font-weight: 400;\">elasticsearch.username: \"kibana_system\"<\/span>\n\n<span style=\"font-weight: 400;\">elasticsearch.password: \"password\"<\/span>\n\n<span style=\"font-weight: 400;\">server.ssl.enabled: true<\/span>\n\n<span style=\"font-weight: 400;\">server.ssl.certificate: \/path\/to\/kibana.crt<\/span>\n\n<span style=\"font-weight: 400;\">server.ssl.key: \/path\/to\/kibana.key<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 2: Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Kibana<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Kh\u1edfi \u0111\u1ed9ng l\u1ea1i Kibana \u0111\u1ec3 \u00e1p d\u1ee5ng c\u1ea5u h\u00ecnh m\u1edbi:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">bin\/kibana<\/span><\/pre>\n<h4><b>C\u00e0i \u0111\u1eb7t SSL\/TLS n\u00e2ng cao<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Mutual TLS (mTLS) b\u1ed5 sung th\u00eam m\u1ed9t l\u1edbp b\u1ea3o m\u1eadt b\u1eb1ng c\u00e1ch y\u00eau c\u1ea7u c\u1ea3 m\u00e1y ch\u1ee7 v\u00e0 m\u00e1y kh\u00e1ch x\u00e1c th\u1ef1c l\u1eabn nhau b\u1eb1ng ch\u1ee9ng ch\u1ec9.<\/span><\/p>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 1: C\u1ea5u h\u00ecnh Elasticsearch cho mTLS<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Trong t\u1ec7p elasticsearch.yml, h\u00e3y b\u1eadt x\u00e1c th\u1ef1c m\u00e1y kh\u00e1ch:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">xpack.security.http.ssl.client_authentication: required<\/span>\n\n<span style=\"font-weight: 400;\">xpack.security.http.ssl.certificate_authorities: [\"\/path\/to\/elastic-stack-ca.crt\"]<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 2: C\u1ea5u h\u00ecnh m\u00e1y kh\u00e1ch cho mTLS<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Khi th\u1ef1c hi\u1ec7n y\u00eau c\u1ea7u, h\u00e3y \u0111\u1ea3m b\u1ea3o m\u00e1y kh\u00e1ch s\u1eed d\u1ee5ng ch\u1ee9ng ch\u1ec9 do CA k\u00fd:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl --cert \/path\/to\/client.crt --key \/path\/to\/client.key --cacert \/path\/to\/elastic-stack-ca.crt https:\/\/localhost:9200<\/span><\/pre>\n<h4><b>\u0110i\u1ec1u ch\u1ec9nh hi\u1ec7u su\u1ea5t SSL\/TLS<\/b><\/h4>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 1: B\u1eadt Session Caching<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">B\u1eadt Session Caching \u0111\u1ec3 c\u1ea3i thi\u1ec7n hi\u1ec7u su\u1ea5t cho c\u00e1c k\u1ebft n\u1ed1i l\u1eb7p l\u1ea1i:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">xpack.security.transport.ssl.session_cache_size: 1000<\/span>\n\n<span style=\"font-weight: 400;\">xpack.security.transport.ssl.session_cache_timeout: 5m<\/span><\/pre>\n<ul>\n<li aria-level=\"1\"><b>B\u01b0\u1edbc 2: S\u1eed d\u1ee5ng B\u1ed9 m\u00e3 h\u00f3a m\u1ea1nh<\/b><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">\u0110\u1ea3m b\u1ea3o b\u1ea1n s\u1eed d\u1ee5ng b\u1ed9 m\u00e3 h\u00f3a m\u1ea1nh v\u00e0 an to\u00e0n:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">xpack.security.transport.ssl.supported_protocols: [ \"TLSv1.2\", \"TLSv1.3\" ]<\/span>\n\n<span style=\"font-weight: 400;\">xpack.security.http.ssl.supported_protocols: [ \"TLSv1.2\", \"TLSv1.3\" ]<\/span><\/pre>\n<h3><b>Qu\u1ea3n l\u00fd ki\u1ec3m so\u00e1t truy c\u1eadp<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">RBAC l\u00e0 ph\u01b0\u01a1ng ph\u00e1p \u0111i\u1ec1u ch\u1ec9nh quy\u1ec1n truy c\u1eadp v\u00e0o h\u1ec7 th\u1ed1ng ho\u1eb7c m\u1ea1ng d\u1ef1a tr\u00ean vai tr\u00f2 c\u1ee7a t\u1eebng ng\u01b0\u1eddi d\u00f9ng trong m\u1ed9t t\u1ed5 ch\u1ee9c. C\u00e1c vai tr\u00f2 x\u00e1c \u0111\u1ecbnh h\u00e0nh \u0111\u1ed9ng n\u00e0o ng\u01b0\u1eddi d\u00f9ng c\u00f3 th\u1ec3 th\u1ef1c hi\u1ec7n v\u00e0 d\u1eef li\u1ec7u n\u00e0o h\u1ecd c\u00f3 th\u1ec3 truy c\u1eadp. Trong b\u1ed1i c\u1ea3nh c\u1ee7a Elasticsearch v\u00e0 Kibana, RBAC c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 h\u1ea1n ch\u1ebf quy\u1ec1n truy c\u1eadp v\u00e0o c\u00e1c t\u00e0i li\u1ec7u ho\u1eb7c tr\u01b0\u1eddng c\u1ee5 th\u1ec3 trong m\u1ed9t ch\u1ec9 m\u1ee5c.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110i\u1ec1u ki\u1ec7n ti\u00ean quy\u1ebft:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elasticsearch v\u00e0 Kibana \u0111\u00e3 \u0111\u01b0\u1ee3c c\u00e0i \u0111\u1eb7t v\u00e0 ch\u1ea1y t\u1ed1t.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Hi\u1ec3u ki\u1ebfn th\u1ee9c c\u01a1 b\u1ea3n v\u1ec1 ch\u1ec9 m\u1ee5c, t\u00e0i li\u1ec7u v\u00e0 REST API c\u1ee7a Elasticsearch .<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u00ednh n\u0103ng b\u1ea3o m\u1eadt X-Pack \u0111\u01b0\u1ee3c b\u1eadt trong thi\u1ebft l\u1eadp Elasticsearch c\u1ee7a b\u1ea1n.<\/span><\/li>\n<\/ul>\n<h4><b>B\u1eadt t\u00ednh n\u0103ng b\u1ea3o m\u1eadt X-Pack<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">C\u00e1c t\u00ednh n\u0103ng b\u1ea3o m\u1eadt c\u1ee7a X-Pack ph\u1ea3i \u0111\u01b0\u1ee3c b\u1eadt \u0111\u1ec3 s\u1eed d\u1ee5ng RBAC trong Elasticsearch v\u00e0 Kibana. N\u1ebfu b\u1ea1n ch\u01b0a b\u1eadt, h\u00e3y th\u1ef1c hi\u1ec7n b\u1eb1ng c\u00e1ch th\u00eam c\u1ea5u h\u00ecnh sau v\u00e0o t\u1ec7p elasticsearch.yml c\u1ee7a m\u00ecnh:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">xpack.security.enabled: true<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">T\u00ednh n\u0103ng b\u1ea3o m\u1eadt (security features) \u0111\u01b0\u1ee3c b\u1eadt trong thi\u1ebft l\u1eadp Elasticsearch c\u1ee7a b\u1ea1n.<\/span><\/p>\n<h4><b>Thi\u1ebft l\u1eadp ki\u1ec3m so\u00e1t truy c\u1eadp d\u1ef1a tr\u00ean vai tr\u00f2<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 qu\u1ea3n l\u00fd RBAC d\u1ef1a tr\u00ean gi\u00e1 tr\u1ecb tr\u01b0\u1eddng, b\u1ea1n th\u1ef1c hi\u1ec7n c\u00e1c b\u01b0\u1edbc sau:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">X\u00e1c \u0111\u1ecbnh vai tr\u00f2 v\u1edbi b\u1ea3o m\u1eadt c\u1ea5p \u0111\u1ed9 t\u00e0i li\u1ec7u v\u00e0 c\u1ea5p \u0111\u1ed9 tr\u01b0\u1eddng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u1ea1o ng\u01b0\u1eddi d\u00f9ng v\u00e0 ch\u1ec9 \u0111\u1ecbnh vai tr\u00f2 cho h\u1ecd.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng c\u00e1c vai tr\u00f2 v\u00e0 ng\u01b0\u1eddi d\u00f9ng n\u00e0y \u0111\u1ec3 ki\u1ec3m so\u00e1t quy\u1ec1n truy c\u1eadp trong Kibana.<\/span><\/li>\n<\/ul>\n<p><b>B\u01b0\u1edbc 1:<\/b> <b>X\u00e1c \u0111\u1ecbnh vai tr\u00f2 v\u1edbi b\u1ea3o m\u1eadt c\u1ea5p \u0111\u1ed9 t\u00e0i li\u1ec7u v\u00e0 c\u1ea5p \u0111\u1ed9 tr\u01b0\u1eddng<\/b><\/p>\n<p><span style=\"font-weight: 400;\">B\u1ea1n c\u00f3 th\u1ec3 x\u00e1c \u0111\u1ecbnh vai tr\u00f2 trong Elasticsearch b\u1eb1ng Kibana UI ho\u1eb7c REST API. H\u00e3y b\u1eaft \u0111\u1ea7u b\u1eb1ng c\u00e1ch t\u1ea1o c\u00e1c vai tr\u00f2 h\u1ea1n ch\u1ebf quy\u1ec1n truy c\u1eadp d\u1ef1a tr\u00ean gi\u00e1 tr\u1ecb tr\u01b0\u1eddng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng Kibana:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elasticsearch 7.x: Management &gt; Security &gt; Roles<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Elasticsearch 8.x: Stack Management &gt; Security &gt; Roles<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Nh\u1ea5p v\u00e0o Create role.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">X\u00e1c \u0111\u1ecbnh t\u00ean vai tr\u00f2 v\u00e0 quy\u1ec1n ch\u1ec9 m\u1ee5c.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng Document Level Security \u0111\u1ec3 th\u00eam truy v\u1ea5n l\u1ecdc t\u00e0i li\u1ec7u d\u1ef1a tr\u00ean gi\u00e1 tr\u1ecb tr\u01b0\u1eddng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng Field Level Security \u0111\u1ec3 h\u1ea1n ch\u1ebf quy\u1ec1n truy c\u1eadp v\u00e0o c\u00e1c tr\u01b0\u1eddng c\u1ee5 th\u1ec3.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng REST API:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Sau \u0111\u00e2y l\u00e0 v\u00ed d\u1ee5 v\u1ec1 c\u00e1ch t\u1ea1o vai tr\u00f2 b\u1eb1ng REST API :<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl -X POST \"localhost:9200\/_security\/role\/sales_role\" -H 'Content-Type: application\/json' -d'<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"indices\": [<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"names\": [ \"sales_data\" ],<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"privileges\": [ \"read\" ],<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"term\": { \"department\": \"sales\" }<\/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\u00a0\u00a0\"field_security\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"grant\": [ \"customer_name\", \"purchase_amount\", \"department\" ]<\/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><b>B\u01b0\u1edbc 2: T\u1ea1o ng\u01b0\u1eddi d\u00f9ng v\u00e0 ch\u1ec9 \u0111\u1ecbnh vai tr\u00f2<\/b><\/p>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng Kibana:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">M\u1edf Kibana v\u00e0 \u0111i t\u1edbi Management &gt; Security &gt; Users.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Nh\u1ea5p v\u00e0o Create user.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">\u0110i\u1ec1n t\u00ean ng\u01b0\u1eddi d\u00f9ng, m\u1eadt kh\u1ea9u v\u00e0 ch\u1ec9 \u0111\u1ecbnh vai tr\u00f2 b\u1ea1n \u0111\u00e3 t\u1ea1o.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng REST API:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">T\u1ea1o ng\u01b0\u1eddi d\u00f9ng v\u00e0 ch\u1ec9 \u0111\u1ecbnh vai tr\u00f2 b\u1eb1ng REST API :<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl -X POST \"localhost:9200\/_security\/user\/john_doe\" -H 'Content-Type: application\/json' -d'<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"password\" : \"password123\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"roles\" : [ \"sales_role\" ],<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"full_name\" : \"John Doe\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"email\" : \"john.doe@example.com\"<\/span>\n\n<span style=\"font-weight: 400;\">}'<\/span><\/pre>\n<p><b>B\u01b0\u1edbc 3:<\/b> <b>X\u00e1c minh quy\u1ec1n ki\u1ec3m so\u00e1t truy c\u1eadp<\/b><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 x\u00e1c minh r\u1eb1ng ki\u1ec3m so\u00e1t truy c\u1eadp \u0111ang ho\u1ea1t \u0111\u1ed9ng, h\u00e3y \u0111\u0103ng nh\u1eadp v\u00e0o Kibana v\u1edbi t\u01b0 c\u00e1ch l\u00e0 ng\u01b0\u1eddi d\u00f9ng b\u1ea1n \u0111\u00e3 t\u1ea1o v\u00e0 th\u1eed truy c\u1eadp d\u1eef li\u1ec7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5: Truy v\u1ea5n d\u1eef li\u1ec7u v\u1edbi quy\u1ec1n truy c\u1eadp b\u1ecb h\u1ea1n ch\u1ebf &#8211; \u0110\u0103ng nh\u1eadp v\u1edbi t\u00ean john_doe v\u00e0 th\u1ef1c hi\u1ec7n truy v\u1ea5n t\u00ecm ki\u1ebfm:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">curl -u john_doe:password123 -X GET \"localhost:9200\/sales_data\/_search\" -H 'Content-Type: application\/json' -d'<\/span>\n\n<span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"query\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"match_all\": {}<\/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;\">Output: Ph\u1ea3n h\u1ed3i ch\u1ec9 n\u00ean bao g\u1ed3m c\u00e1c t\u00e0i li\u1ec7u t\u1eeb ch\u1ec9 m\u1ee5c sales_data trong \u0111\u00f3 gi\u00e1 tr\u1ecb tr\u01b0\u1eddng department l\u00e0 sales v\u00e0 ch\u1ec9 n\u00ean hi\u1ec3n th\u1ecb c\u00e1c tr\u01b0\u1eddng customer_name, purchase_amount v\u00e0 department:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">{<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"took\": 5,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"timed_out\": false,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"_shards\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"total\": 1,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"successful\": 1,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"skipped\": 0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"failed\": 0<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0},<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\"hits\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"total\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"value\": 1,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"relation\": \"eq\"<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0},<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"max_score\": 1.0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\"hits\": [<\/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\u00a0\u00a0\u00a0\u00a0\"_index\": \"sales_data\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"_id\": \"1\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"_score\": 1.0,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"_source\": {<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"customer_name\": \"Alice Smith\",<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"purchase_amount\": 100,<\/span>\n\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\"department\": \"sales\"<\/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<h2><span class=\"ez-toc-section\" id=\"Cau_hoi_thuong_gap_ve_Elasticsearch_tutorial\"><\/span><b>C\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 Elasticsearch tutorial<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><b>Elasticsearch c\u00f3 y\u00eau c\u1ea7u gi\u1ea5y ph\u00e9p kh\u00f4ng?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Elasticsearch l\u00e0 c\u00f4ng c\u1ee5 t\u00ecm ki\u1ebfm v\u00e0 ph\u00e2n t\u00edch d\u1eef li\u1ec7u m\u00e3 ngu\u1ed3n m\u1edf, \u0111\u01b0\u1ee3c cung c\u1ea5p mi\u1ec5n ph\u00ed theo Gi\u1ea5y ph\u00e9p Elastic. B\u1ea1n c\u00f3 th\u1ec3 t\u1ea3i xu\u1ed1ng v\u00e0 s\u1eed d\u1ee5ng Elasticsearch m\u00e0 kh\u00f4ng ph\u1ea3i tr\u1ea3 ph\u00ed. Tuy nhi\u00ean, c\u1ea7n l\u01b0u \u00fd r\u1eb1ng phi\u00ean b\u1ea3n mi\u1ec5n ph\u00ed n\u00e0y c\u00f3 m\u1ed9t s\u1ed1 h\u1ea1n ch\u1ebf.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">C\u1ee5 th\u1ec3, m\u1ed9t s\u1ed1 t\u00ednh n\u0103ng n\u00e2ng cao c\u1ee7a Elasticsearch nh\u01b0:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">H\u1ecdc m\u00e1y (Machine Learning)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">B\u1ea3o m\u1eadt (Security)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1c ch\u1ee9c n\u0103ng qu\u1ea3n l\u00fd n\u00e2ng cao (Advanced Management Functions)<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Nh\u1eefng t\u00ednh n\u0103ng n\u00e0y c\u00f3 th\u1ec3 b\u1ecb gi\u1edbi h\u1ea1n ho\u1eb7c ch\u1ec9 kh\u1ea3 d\u1ee5ng trong c\u00e1c phi\u00ean b\u1ea3n tr\u1ea3 ph\u00ed.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ec v\u1eady, khi s\u1eed d\u1ee5ng phi\u00ean b\u1ea3n mi\u1ec5n ph\u00ed c\u1ee7a Elasticsearch, b\u1ea1n n\u00ean:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ki\u1ec3m tra k\u1ef9 c\u00e1c \u0111i\u1ec1u kho\u1ea3n v\u00e0 \u0111i\u1ec1u ki\u1ec7n c\u1ee7a Gi\u1ea5y ph\u00e9p Elastic \u0111\u1ec3 hi\u1ec3u r\u00f5 nh\u1eefng t\u00ednh n\u0103ng n\u00e0o \u0111\u01b0\u1ee3c ph\u00e9p s\u1eed d\u1ee5ng.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e2n nh\u1eafc nhu c\u1ea7u c\u1ee7a d\u1ef1 \u00e1n \u0111\u1ec3 quy\u1ebft \u0111\u1ecbnh xem phi\u00ean b\u1ea3n mi\u1ec5n ph\u00ed c\u00f3 \u0111\u00e1p \u1ee9ng \u0111\u01b0\u1ee3c y\u00eau c\u1ea7u hay kh\u00f4ng, ho\u1eb7c c\u00f3 c\u1ea7n thi\u1ebft ph\u1ea3i n\u00e2ng c\u1ea5p l\u00ean phi\u00ean b\u1ea3n tr\u1ea3 ph\u00ed \u0111\u1ec3 t\u1eadn d\u1ee5ng \u0111\u1ea7y \u0111\u1ee7 c\u00e1c t\u00ednh n\u0103ng n\u00e2ng cao hay kh\u00f4ng.<\/span><\/li>\n<\/ul>\n<h3><b>Elasticsearch c\u00f3 th\u1ec3 x\u1eed l\u00fd bao nhi\u00eau t\u00e0i li\u1ec7u?<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Theo m\u1eb7c \u0111\u1ecbnh, Elasticsearch gi\u1edbi h\u1ea1n s\u1ed1 l\u01b0\u1ee3ng t\u00e0i li\u1ec7u \u0111\u01b0\u1ee3c tr\u1ea3 v\u1ec1 trong m\u1ed9t truy v\u1ea5n duy nh\u1ea5t \u0111\u1ec3 ng\u0103n ch\u1eb7n vi\u1ec7c ti\u00eau th\u1ee5 t\u00e0i nguy\u00ean qu\u00e1 m\u1ee9c. Gi\u1edbi h\u1ea1n m\u1eb7c \u0111\u1ecbnh \u0111\u01b0\u1ee3c \u0111\u1eb7t \u1edf m\u1ee9c 10.000 t\u00e0i li\u1ec7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">N\u1ebfu ch\u1ec9 m\u1ee5c ch\u1ee9a nhi\u1ec1u h\u01a1n 10.000 t\u00e0i li\u1ec7u, vi\u1ec7c ch\u1ea1y truy v\u1ea5n \u201cmatch_all\u201d s\u1ebd kh\u00f4ng tr\u1ea3 v\u1ec1 t\u1ea5t c\u1ea3 c\u00e1c t\u00e0i li\u1ec7u trong m\u1ed9t truy v\u1ea5n duy nh\u1ea5t. Thay v\u00e0o \u0111\u00f3, Elasticsearch s\u1ebd ch\u1ec9 tr\u1ea3 v\u1ec1 10.000 t\u00e0i li\u1ec7u \u0111\u1ea7u ti\u00ean. \u0110i\u1ec1u n\u00e0y \u0111\u01b0\u1ee3c g\u1ecdi l\u00e0 gi\u1edbi h\u1ea1n \u201cindex.max_result_window\u201d.<\/span><\/p>\n<h3><b>C\u00f3 th\u1ec3 h\u1ecdc Elasticsearch \u1edf \u0111\u00e2u?<\/b><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.udemy.com\/course\/elasticsearch-java\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Elasticsearch Masterclass For Java Spring Developers [2025]<\/span><\/a><span style=\"font-weight: 400;\">: C\u00e1c kh\u00e1i ni\u1ec7m c\u1ed1t l\u00f5i c\u1ee7a Elasticsearch (index, shard, replica&#8230;); t\u1ed5ng h\u1ee3p s\u1ed1 li\u1ec7u; l\u1eadp ch\u1ec9 m\u1ee5c h\u00e0ng lo\u1ea1t &amp; t\u1ed1i \u01b0u h\u00f3a truy v\u1ea5n; t\u00edch h\u1ee3p Spring Boot; t\u00ecm ki\u1ebfm to\u00e0n v\u0103n b\u1ea3n; m\u00f4 h\u00ecnh h\u00f3a d\u1eef li\u1ec7u; b\u1ea3o m\u1eadt &#8211; x\u00e1c th\u1ef1c SSL\/TLS\u2026<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.udemy.com\/course\/elasticsearch-masterclass\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Elasticsearch Masterclass [Incl., Elasticsearch 7 update]<\/span><\/a><span style=\"font-weight: 400;\">: T\u00ecm hi\u1ec3u to\u00e0n b\u1ed9 Elastic Stack (Elasticsearch &#8211; Logstash &#8211; Kibana)<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.udemy.com\/course\/elasticsearch-as-you-have-never-known-it-before\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">ElasticSearch as you have never known it before<\/span><\/a><span style=\"font-weight: 400;\">: T\u1eeb h\u1ec7 th\u1ed1ng t\u00ecm ki\u1ebfm c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao, m\u00f4-\u0111un \u0111\u1ec1 xu\u1ea5t, t\u00edch h\u1ee3p php\/python\/java t\u1ea1i v\u00ed d\u1ee5 th\u1ef1c t\u1ebf Elasticsearch.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.udemy.com\/course\/elasticsearch-7-and-elastic-stack\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Elasticsearch 8 and the Elastic Stack<\/span><\/a><span style=\"font-weight: 400;\">: Chi ti\u1ebft v\u00e0 th\u1ef1c h\u00e0nh t\u00ecm ki\u1ebfm Elastic ho\u00e0n ch\u1ec9nh &#8211; t\u00ecm ki\u1ebfm, ph\u00e2n t\u00edch v\u00e0 tr\u1ef1c quan h\u00f3a d\u1eef li\u1ec7u l\u1edbn v\u1edbi Elasticsearch, Kibana, Logstash v\u00e0 Beats;<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><a href=\"https:\/\/www.udemy.com\/course\/elasticsearch-search-api-and-query-dsl-in-practice\/\" target=\"_blank\" rel=\"noopener\"><span style=\"font-weight: 400;\">Elasticsearch Queries In Practice<\/span><\/a><span style=\"font-weight: 400;\">: H\u01b0\u1edbng d\u1eabn \u0111\u1ea7y \u0111\u1ee7 v\u1ec1 Elasticsearch Query DSL, Search API, t\u1ed1i \u01b0u h\u00f3a &amp; \u0111i\u1ec1u ch\u1ec9nh.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket_Elasticsearch_tutorial\"><\/span><b>T\u1ed5ng k\u1ebft Elasticsearch tutorial<\/b><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Kh\u1ea3 n\u0103ng m\u1edf r\u1ed9ng linh ho\u1ea1t v\u00e0 hi\u1ec7u su\u1ea5t v\u01b0\u1ee3t tr\u1ed9i c\u1ee7a Elasticsearch cho ph\u00e9p c\u00e1c k\u1ef9 s\u01b0 gi\u1ea3i quy\u1ebft th\u00e1ch th\u1ee9c v\u1ec1 d\u1eef li\u1ec7u l\u1edbn. T\u1eeb vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng t\u00ecm ki\u1ebfm ph\u1ee9c t\u1ea1p \u0111\u1ebfn ph\u00e2n t\u00edch truy c\u1eadp v\u00e0 gi\u00e1m s\u00e1t h\u1ec7 th\u1ed1ng, Elasticsearch cung c\u1ea5p m\u1ed9t b\u1ed9 c\u00f4ng c\u1ee5 m\u1ea1nh m\u1ebd \u0111\u1ec3 t\u1ed1i \u01b0u h\u00f3a hi\u1ec7u su\u1ea5t v\u00e0 \u0111\u01b0a ra quy\u1ebft \u0111\u1ecbnh d\u1ef1a tr\u00ean d\u1eef li\u1ec7u. H\u00e3y kh\u00e1m ph\u00e1 Elasticsearch theo h\u01b0\u1edbng d\u1eabn ITviec v\u1eeba chia s\u1ebb \u0111\u1ec3 n\u00e2ng cao kh\u1ea3 n\u0103ng x\u1eed l\u00fd d\u1eef li\u1ec7u v\u00e0 x\u00e2y d\u1ef1ng c\u00e1c gi\u1ea3i ph\u00e1p ti\u00ean ti\u1ebfn trong l\u0129nh v\u1ef1c IT.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>B\u1ea1n mu\u1ed1n t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u si\u00eau t\u1ed1c, ph\u00e2n t\u00edch l\u01b0\u1ee3ng th\u00f4ng tin kh\u1ed5ng l\u1ed3 v\u00e0 x\u00e2y d\u1ef1ng \u1ee9ng d\u1ee5ng m\u1ea1nh m\u1ebd? Elasticsearch l\u00e0 c\u00f4ng c\u1ee5 s\u1ebd bi\u1ebfn d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n th\u00e0nh s\u1ee9c m\u1ea1nh, cho ph\u00e9p b\u1ea1n kh\u00e1m ph\u00e1 th\u00f4ng tin ch\u1ec9 trong \u201ct\u00edch t\u1eafc\u201d. B\u00e0i vi\u1ebft n\u00e0y s\u1ebd xoay quanh c\u00e1c Elasticsearch tutorial [&hellip;]<\/p>\n","protected":false},"author":205,"featured_media":85451,"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-85446","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.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n - ITviec Blog<\/title>\n<meta name=\"description\" content=\"Elasticsearch tutorial t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao: C\u00e1ch c\u00e0i \u0111\u1eb7t, l\u1eadp ch\u1ec9 m\u1ee5c, truy v\u1ea5n, t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u, t\u1ed1i \u01b0u hi\u1ec7u su\u1ea5t v\u00e0 h\u01a1n th\u1ebf n\u1eefa.\" \/>\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-elasticsearch-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n\" \/>\n<meta property=\"og:description\" content=\"B\u1ea1n mu\u1ed1n t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u si\u00eau t\u1ed1c, ph\u00e2n t\u00edch l\u01b0\u1ee3ng th\u00f4ng tin kh\u1ed5ng l\u1ed3 v\u00e0 x\u00e2y d\u1ef1ng \u1ee9ng d\u1ee5ng m\u1ea1nh m\u1ebd? Elasticsearch l\u00e0 c\u00f4ng c\u1ee5 s\u1ebd bi\u1ebfn d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/\" \/>\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-03-31T08:16:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-17T02:12:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/03\/elasticsearch-tutorial-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=\"27 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n - ITviec Blog","description":"Elasticsearch tutorial t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao: C\u00e1ch c\u00e0i \u0111\u1eb7t, l\u1eadp ch\u1ec9 m\u1ee5c, truy v\u1ea5n, t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u, t\u1ed1i \u01b0u hi\u1ec7u su\u1ea5t v\u00e0 h\u01a1n th\u1ebf n\u1eefa.","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-elasticsearch-tutorial\/","og_locale":"vi_VN","og_type":"article","og_title":"Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n","og_description":"B\u1ea1n mu\u1ed1n t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u si\u00eau t\u1ed1c, ph\u00e2n t\u00edch l\u01b0\u1ee3ng th\u00f4ng tin kh\u1ed5ng l\u1ed3 v\u00e0 x\u00e2y d\u1ef1ng \u1ee9ng d\u1ee5ng m\u1ea1nh m\u1ebd? Elasticsearch l\u00e0 c\u00f4ng c\u1ee5 s\u1ebd bi\u1ebfn d\u1eef li\u1ec7u c\u1ee7a b\u1ea1n","og_url":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-03-31T08:16:36+00:00","article_modified_time":"2025-06-17T02:12:49+00:00","og_image":[{"width":640,"height":337,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/03\/elasticsearch-tutorial-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":"27 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/"},"author":{"name":"H\u00e0 My","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/7bd099db44e5079508c9b7e8c0161e3c"},"headline":"Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n","datePublished":"2025-03-31T08:16:36+00:00","dateModified":"2025-06-17T02:12:49+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/"},"wordCount":7126,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/03\/elasticsearch-tutorial-vippro-scaled.png","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/","url":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/","name":"Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/03\/elasticsearch-tutorial-vippro-scaled.png","datePublished":"2025-03-31T08:16:36+00:00","dateModified":"2025-06-17T02:12:49+00:00","description":"Elasticsearch tutorial t\u1eeb c\u01a1 b\u1ea3n \u0111\u1ebfn n\u00e2ng cao: C\u00e1ch c\u00e0i \u0111\u1eb7t, l\u1eadp ch\u1ec9 m\u1ee5c, truy v\u1ea5n, t\u00ecm ki\u1ebfm d\u1eef li\u1ec7u, t\u1ed1i \u01b0u hi\u1ec7u su\u1ea5t v\u00e0 h\u01a1n th\u1ebf n\u1eefa.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/03\/elasticsearch-tutorial-vippro-scaled.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/03\/elasticsearch-tutorial-vippro-scaled.png","width":640,"height":337,"caption":"elasticsearch tutorial - vippro"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/huong-dan-elasticsearch-tutorial\/#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":"Elasticsearch tutorial: Chi ti\u1ebft c\u00e1ch s\u1eed d\u1ee5ng Elasticsearch c\u01a1 b\u1ea3n"}]},{"@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\/85446","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=85446"}],"version-history":[{"count":2,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/85446\/revisions"}],"predecessor-version":[{"id":88165,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/85446\/revisions\/88165"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/85451"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=85446"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=85446"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=85446"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}