{"id":5002,"date":"2021-06-18T10:31:37","date_gmt":"2021-06-18T02:31:37","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=5002"},"modified":"2021-06-18T10:31:36","modified_gmt":"2021-06-18T02:31:36","slug":"%e5%a6%82%e4%bd%95%e9%80%9a%e8%bf%87hbase-shell%e5%88%9b%e5%bb%ba%e5%85%a8%e6%96%87%e7%b4%a2%e5%bc%95","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=5002","title":{"rendered":"\u5982\u4f55\u901a\u8fc7 hbase shell \u521b\u5efa\u5168\u6587\u7d22\u5f15"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>\u672c\u6848\u4f8b\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7 hbase shell \u6307\u4ee4\u521b\u5efa\u5168\u6587\u7d22\u5f15\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<h4>1. \u5728inceptor\u4e2d\u521b\u5efahbase\u8868<\/h4>\n<p>\u5728 inceptor \u4e2d\u521b\u5efa\u8868\u540d\u4e3a hbase_fulltext_test \u7684 hbase \u8868\uff0c\u8be5\u8868\u6709 key1\u3001c1\u3001c2\u3001c3 \u56db\u5217\uff0c\u6620\u5c04\u5230 hyperbase \u4e2d\u7684\u8868\u4e3a hbase_fulltext_test\uff0c\u5217\u65cf\u4e3a f\uff0c\u5217\u9650\u5b9a\u7b26\u5206\u522b\u5bf9\u5e94 rowkey\u3001q1\u3001q2\u3001q3\uff0c\u8be5\u6620\u5c04\u5173\u7cfb\u53ef\u4ee5\u901a\u8fc7\u547d\u4ee4 <strong>describe formatted<\/strong> \u67e5\u770b\u3002<\/p>\n<pre><code class=\"language-sql\"> CREATE TABLE hbase_fulltext_test(key1 string,c1 string,c2 string,c3 string) \n STORED by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler';<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610071618455.png\" alt=\"file\" \/><\/p>\n<p>\u67e5\u770b\u8868\u7684\u5143\u6570\u636e\u4fe1\u606f\u3002<\/p>\n<pre><code class=\"language-sql\">> describe formatted hbase_fulltext_test;<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610071967745.png\" alt=\"file\" \/><\/p>\n<h4>2. \u5728hbase shell\u4e2d\u5bfc\u51fa\u914d\u7f6e\u6587\u4ef6<\/h4>\n<p>2.1. \u5728\u5bbf\u4e3b\u673a\u4e0a\u521b\u5efa\u4e00\u4e2a\u8be5\u8868\u7684json\u914d\u7f6e\u4fe1\u606f\u4fdd\u5b58\u6587\u4ef6\uff0c\u5982 \/root\/mll\/hbase_fulltext_test.json<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610072097693.png\" alt=\"file\" \/><\/p>\n<p>2.2. \u8fdb\u5165hbase shell\u5bfc\u51fa\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre><code class=\"language-sql\">> describeInJson 'hbase_fulltext_test', 'true','\/root\/mll\/hbase_fulltext_test.json'<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610072241177.png\" alt=\"file\" \/><\/p>\n<p>\u67e5\u770b\u5bfc\u51fa\u7684json\u6587\u4ef6<br \/>\n<img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610072280700.png\" alt=\"file\" \/><\/p>\n<h4>3. json\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u5168\u6587\u7d22\u5f15\u90e8\u5206\u8bf4\u660e<\/h4>\n<pre><code class=\"language-json\">\"fulltextindex\" \uff1a {\n     \/\/ \u5fc5\u586b\u9879\uff0chbase\u8868\u540d\n    \"tableName\":\"tableName\",  \n    \/\/ \u5fc5\u586b\u9879\uff0cboolean\u503c\uff0c\u8868\u793a\u662f\u5426\u5141\u8bb8\u5bf9\u5efa\u7d22\u5f15\u5217\u8fdb\u884cupdate\u64cd\u4f5c\uff0c\u5982\u679c\u8bbe\u7f6e\u4e3afalse\uff0c\u5219hbase\u4e2dput\/delete\u9700\u8981\u5b8c\u5168\u8986\u76d6\u6216\u5b8c\u5168\u4e0d\u6d89\u53ca\u9700\u8981\u7d22\u5f15\u7684column\uff1b\n    \"allowUpdate\":\"true\/false\",       \n    \/\/ \u53ef\u9009\u9879\uff0c\u8868\u793a\u7d22\u5f15\u6570\u636e\u7684ttl\u65f6\u95f4\uff0c\u5355\u4f4d\u6beb\u79d2\uff0c0\u6216\u4e0d\u586b\u8868\u793a\u4e0d\u8fdb\u884c\u6570\u636ettl\uff0c\u9ed8\u8ba4\u4e3a0\uff1b\n    \"ttl\" : 3600000,            \n    \/\/ \u53ef\u9009\u9879\uff0c\u8868\u793a\u662f\u5426\u5728es\u4e2d\u5b58\u50a8_source\u4fe1\u606f\uff0c\u9ed8\u8ba4\u4e3atrue\uff1b\u8bbe\u7f6e\u4e3afalse\uff0c\u53ef\u4ee5\u52a0\u901frebuild_fulltext_index\uff0c\u51cf\u5c11\u7d22\u5f15\u5927\u5c0f\uff1b\n    \"source\" : true\/false,   \n    \/\/ \u53ef\u9009\u9879\uff0c\u8868\u793a\u662f\u5426\u5728es\u4e2d\u5b58\u50a8_all\u4fe1\u606f\uff0c\u9ed8\u8ba4\u4e3afalse\uff1b\n    \"all\" : \"true\/false\", \n    \/\/ \u5fc5\u586b\u9879\uff0cfield\u6570\u7ec4\uff0c\u6bcf\u4e2afield\u63cf\u8ff0\u4e00\u4e2ahbase\u5217\u7684\u7d22\u5f15\u4fe1\u606f\uff1b\n    \"fields\":[\n    {\n        \/\/ \u5fc5\u586b\u9879\uff0c\u5217\u65cf\u540d\uff1b\n        \"family\" : \"string\", \n        \/\/ \u5fc5\u586b\u9879\uff0c\u5217\u9650\u5b9a\u7b26\uff0c\u5bf9\u8be5\u5217\u5efa\u7acb\u5168\u6587\u7d22\u5f15\uff1b\n        \"qualifier\" : \"string\",  \n        \/\/ \u53ef\u9009\u9879\uff0c\u5982\u679ctype != string\uff0c\u8be5\u5c5e\u6027\u8868\u793a\u5728hbase\u4e2d\u5b58\u50a8\u7684byte\u6570\u7ec4\u662f\u5426\u662f\u7531\u7279\u5b9a\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u6210\u7684\uff0c\u4ee5type == long\uff0c\u503c\u4e3a123\u4e3e\u4f8b\uff0c\u5f53\u8be5\u503c\u4e3atrue\u662f\uff0chbase\u4e2d\u5b58\u50a8\u7684byte[]\u662fBytes.toBytes(\"123\")\uff0c\u5f53\u8be5\u503c\u4e3afalse\u65f6\uff0chbase\u4e2d\u5b58\u50a8\u7684byte[]\u662fBytes.toBytes(123)\uff0c\u9ed8\u8ba4\u4e3afalse\uff1b\n        \"encode_as_string\" : \"true\", \n        \"attributes\" : {\n            \/\/ \u53ef\u9009\u9879\uff0c\u6570\u636e\u7c7b\u578b\uff0c\u9ed8\u8ba4\u4e3astring\uff0c\u9700\u8981\u7279\u6b8a\u6ce8\u610f\u7684\u662fdate\u7c7b\u578b\uff0ces\u4e2d\u7684date\u7c7b\u578b\u652f\u6301string\u7c7b\u578b\u4e0elong\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4f46\u5728hyperbase\u4e2d\uff0cdate\u7c7b\u578b\u53ea\u652f\u6301string\u7c7b\u578b\uff0c\u5176\u683c\u5f0f\u662fes\u4e2d\u7684dateOptionalTime\uff0c\u5982\"2015-01-01\"\u6216\"2015-01-01 12:12:12\"\uff0c\u5982\u679c\u7528\u6237\u7684\u6570\u636e\u662flong\u8868\u793a\uff0c\u8bf7\u4f7f\u7528long\u7c7b\u578b\uff1b\n            \"type\" : \"string\/byte\/short\/integer\/long\/float\/double\/boolean\/date\", \n            \/\/ \u53ef\u9009\u9879\uff0c\u5206\u8bcd\u5668\uff0c\u9ed8\u8ba4\u4f7f\u7528es\u81ea\u5e26\u7684analyzer\uff0c\u4f7f\u7528\u8be5\u914d\u7f6e\u9879\u53ef\u4ee5\u540c\u65f6\u6307\u5b9asearch\u548cindex\u7684analyzer\uff1b\n            \"analyzer\" : \"ik\/mmseg\",  \n            \/\/ \u53ef\u9009\u9879\uff0c\u5355\u72ec\u6307\u5b9asearch\u7684analyzer\uff1b\n            \"search_analyzer\" : \"ik\/mmseg\",  \n            \/\/ \u53ef\u9009\u9879\uff0c\u5355\u72ec\u6307\u5b9aindex\u7684analyzer\uff1b\n            \"index_analyzer\" : \"ik\/mmsge\",   \n            \/\/ \u53ef\u9009\u9879\uff0c\u662f\u5426\u5b58\u50a8\uff0c\u9ed8\u8ba4\u662ftrue\uff1b\n            \"store\" : \"true\/false\",   \n            \/\/ \u53ef\u9009\u9879\uff0c\u662f\u5426\u7d22\u5f15\uff0c\u9ed8\u8ba4\u4e3anot_analyzed\uff1b\n            \"index\" : \"analyzed\/not_analyzed\/no\",  \n            \/\/ \u53ef\u9009\u9879\uff0c\u9ed8\u8ba4\u4e3afalse\u8868\u793a\u4e0d\u542f\u7528\uff1b\n            \"doc_values\" : \"true\/false\",  \n        }\n    }],\n    \"settings\": {\n        \/\/ \u53ef\u9009\u9879\uff0c\u5206\u7247\u6570\uff0c\u5982\u4e0d\u6307\u5b9a\u5219\u4f7f\u7528\u7cfb\u7edf\u9ed8\u8ba4\u5206\u7247\u6570\uff1b\n        \"index.number_of_shards\" : \"10\",  \n        \/\/ \u53ef\u9009\u9879\uff0c\u526f\u672c\u6570\uff0c\u5982\u4e0d\u6307\u5b9a\u5219\u4f7f\u7528\u7cfb\u7edf\u9ed8\u8ba4\u526f\u672c\u6570\uff1b\n        \"index.number_of_replicas\" : \"2\"  \n    }\n}<\/code><\/pre>\n<h4>4. \u4fee\u6539hbase_fulltext_test.json\u914d\u7f6e\u6587\u4ef6<\/h4>\n<p>\u672c\u5b9e\u9a8c\u9488\u5bf9\u5b57\u6bb5 c2 \u521b\u5efa\u5168\u6587\u7d22\u5f15\uff0c\u5373\u6620\u5c04\u5230 hyperbase \u4e2d hbase_fulltext_test \u7684 f:q2 \u5217\u3002<\/p>\n<p>json\u6587\u4ef6\u4fee\u6539\u540e \u201cfulltextindex\u201d \u90e8\u5206\u5185\u5bb9\u4e3a\uff1a<\/p>\n<pre><code class=\"language-shell\">  \"fulltextindex\" : {\n    \"tableName\":\"hbase_fulltext_test\",\n    \"allowUpdate\":\"true\",\n    \"fields\":[\n    { \"family\" : \"f\",\n      \"qualifier\" : \"q2\"\n    }]\n  },<\/code><\/pre>\n<h4>5. \u4f7f\u7528\u4fee\u6539\u540e\u7684json\u6587\u4ef6\u4fee\u6539\u8868\u7ed3\u6784<\/h4>\n<p>\u5728hbase shell\u4e2d\u4f7f\u7528\u547d\u4ee4\u4fee\u6539\u8868\u7ed3\u6784\u3002<\/p>\n<pre><code class=\"language-sql\">> alterUseJson 'hbase_fulltext_test','\/root\/mll\/hbase_fulltext_test.json'<\/code><\/pre>\n<p>\u4e0a\u8ff0\u547d\u4ee4\u6267\u884c\u4e4b\u540e\uff0c\u4f1a\u5728\u63a7\u5236\u53f0\u4ea4\u4e92\u5f0f\u7684\u6253\u5370\u5143\u6570\u636e\u4fe1\u606f\uff0c\u9700\u8981\u624b\u52a8\u8f93\u5165 &#8216;y&#8217; \u6765\u4fee\u6539\u5143\u6570\u636e\u4fe1\u606f\uff0c\u7136\u540e\u7b49\u5f85\u4fee\u6539\u6210\u529f\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610073903956.png\" alt=\"file\" \/><\/p>\n<h4>6. \u9a8c\u8bc1\u5168\u6587\u7d22\u5f15\u662f\u5426\u521b\u5efa\u6210\u529f<\/h4>\n<p>6.1. \u901a\u8fc7\u5728 inceptor \u4e2d\u67e5\u770b\u5143\u6570\u636e\u4fe1\u606f\u6765\u786e\u8ba4<\/p>\n<pre><code class=\"language-sql\">> describe formatted hbase_fulltext_test;<\/code><\/pre>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610073972908.png\" alt=\"file\" \/><\/p>\n<p>6.2. \u901a\u8fc7\u5728 search \u7684 9100\u9875\u9762\u67e5\u770b index\u6765\u786e\u8ba4<\/p>\n<p>\u53ef\u4ee5\u5728search\u9875\u9762\u770b\u5230\u5168\u6587\u7d22\u5f15\u8868 elasticsearch_hbase_fulltext_test\u3002<\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2021\/01\/image-1610074122093.png\" alt=\"file\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u672c\u6848\u4f8b\u4ecb\u7ecd\u5982\u4f55\u901a\u8fc7 hbase shell \u6307\u4ee4\u521b\u5efa\u5168\u6587\u7d22\u5f15\u3002 \u8be6\u7ec6\u8bf4\u660e 1. \u5728inceptor\u4e2d ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=5002\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5002","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/5002","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5002"}],"version-history":[{"count":2,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/5002\/revisions"}],"predecessor-version":[{"id":6068,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/5002\/revisions\/6068"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}