Kouhei Sutou
null+****@clear*****
Tue Jun 20 20:57:22 JST 2017
Kouhei Sutou 2017-06-20 20:57:22 +0900 (Tue, 20 Jun 2017) New Revision: 6c8f61eb0fd0872dd231abfa86972f8206b903f2 https://github.com/pgroonga/pgroonga.github.io/commit/6c8f61eb0fd0872dd231abfa86972f8206b903f2 Message: Improve auto complete document Added files: _po/ja/how-to/auto-complete.po how-to/auto-complete.md ja/how-to/auto-complete.md Removed files: _po/ja/how-to/autocomplete.po how-to/autocomplete.md ja/how-to/autocomplete.md Modified files: _po/ja/how-to/index.po how-to/index.md ja/how-to/index.md Added: _po/ja/how-to/auto-complete.po (+276 -0) 100644 =================================================================== --- /dev/null +++ _po/ja/how-to/auto-complete.po 2017-06-20 20:57:22 +0900 (5364393) @@ -0,0 +1,276 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"PO-Revision-Date: 2017-06-20 20:56+0900\n" +"Language: ja\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "" +"---\n" +"title: How to implement auto complete feature\n" +"---" +msgstr "" +"---\n" +"title: オートコンプリートの実装方法\n" +"---" + +msgid "# How to implement auto complete feature" +msgstr "# オートコンプリート機能の実装方法" + +msgid "" +"Auto complete is useful feature for easy to use search box. PGroonga has featu" +"res to implement auto complete." +msgstr "オートコンプリートは使いやすい検索ボックスを作るのに便利な機能です。Pgroongaにはオートコンプリートを実装するための機能があります。" + +msgid "You can implement auto complete by combining the following searches:" +msgstr "次の検索を組み合わせることでオートコンプリートを実現できます。" + +msgid " * Prefix search" +msgstr " * 前方一致検索" + +msgid " * Only for Japanese: Prefix RK search for auto complete by readings" +msgstr " * 日本語のみ:ヨミガナでのオートコンプリート用に前方一致RK検索" + +msgid " * Loose full text search" +msgstr " * 緩い全文検索" + +msgid "## Sample schema and indexes" +msgstr "## サンプルスキーマとインデックス" + +msgid "Here is the sample schema:" +msgstr "サンプルのスキーマを示します。" + +msgid "" +"```sql\n" +"CREATE TABLE terms (\n" +" term text,\n" +" readings text[]\n" +");\n" +"```" +msgstr "" + +msgid "" +"Auto complete candidate terms are stored into `term`. Readings of `term` are s" +"tored in `readings`. As you know, type of `readings` is `text[]`, multiple rea" +"dings are stored into `readings`." +msgstr "" +"オートコンプリート候補の用語は`term`に保存します。`term`のヨミガナは`readings`に保存します。`readings`の型が`text[]`" +"であることからわかるように、`readings`には複数のヨミガナを保存できます。" + +msgid "Here is the sample index definition:" +msgstr "サンプルのインデックス定義を示します。" + +msgid "" +"```sql\n" +"CREATE INDEX pgroonga_terms_prefix_search ON terms USING pgroonga\n" +" (term pgroonga.text_term_search_ops_v2,\n" +" readings pgroonga.text_array_term_search_ops_v2);" +msgstr "" + +msgid "" +"CREATE INDEX pgroonga_terms_full_text_search ON terms USING pgroonga\n" +" (term pgroonga.text_full_text_search_ops_v2)\n" +" WITH (tokenizer = 'TokenBigramSplitSymbolAlphaDigit');\n" +"```" +msgstr "" + +msgid "The above indexes are required for prefix search and full text search." +msgstr "上記のインデックス定義は前方一致検索と全文検索に必要です。" + +msgid "" +"`TokenBigramSplitSymbolAlphaDigit` tokenizer is suitable for loose full text s" +"earch." +msgstr "`TokenBigramSplitSymbolAlphaDigit`トークナイザーは緩い全文検索に向いています。" + +msgid "## Prefix search" +msgstr "## 前方一致検索" + +msgid "There is a simple way to implement auto complete feature. It is prefix search." +msgstr "オートコンプリート機能を実現するシンプルな方法は前方一致検索を使う方法です。" + +msgid "PGroonga provides operator for it: [`&^` operator][prefix-search-v2]" +msgstr "PGroongaは前方一致検索用の演算子として[`&^`演算子][prefix-search-v2]を提供しています。" + +msgid "Here is the sample data for prefix search:" +msgstr "前方一致検索をするためのサンプルデータを示します。" + +msgid "" +"```sql\n" +"INSERT INTO terms (term) VALUES ('auto-complete');\n" +"```" +msgstr "" + +msgid "Then, use `&^` against `term` for prefix search. Here is the result of it:" +msgstr "データを挿入したら、`term`に対して`&^`を使って前方一致検索をします。結果は次の通りです。" + +msgid "" +"```sql\n" +"SELECT term FROM terms WHERE term &^ 'auto';\n" +"-- term \n" +"-- ---------------\n" +"-- auto-complete\n" +"-- (1 rows)\n" +"```" +msgstr "" + +msgid "The result contains `auto-complete` as auto complete candidate term." +msgstr "オートコンプリート候補の用語として`auto-complete`がヒットしています。" + +msgid "## Only for Japanese: Prefix RK search for auto complete by readings" +msgstr "## 日本語のみ:ヨミガナでのオートコンプリート用に前方一致RK検索" + +msgid "" +"[Prefix RK search][groonga-prefix-rk-search] is a prefix search variant. It su" +"pports searching [katakana][wikipedia-katakana] by [romaji][wikipedia-romaji]," +" [hiragana][wikipedia-hiragana] or katakana. It's useful for Japanese." +msgstr "" +"[前方一致RK検索][groonga-prefix-rk-search]は前方一致検索の一種です。これは[ローマ字][wikipedia-romaji]、[" +"ひらがな][wikipedia-hiragana]またはカタカナで[カタカナ][wikipedia-katakana]を検索できます。日本語にはとても便利な" +"機能です。" + +msgid "Here is the sample data for prefix RK search:" +msgstr "前方一致RK検索のためのサンプルデータを示します。" + +msgid "" +"```sql\n" +"INSERT INTO terms (term, readings) VALUES ('牛乳', ARRAY['ギュウニュウ', 'ミルク']);\n" +"```" +msgstr "" + +msgid "" +"Note that you need insert only katakana in `readings`. This is required to sea" +"rch auto complete candidate terms with prefix RK search." +msgstr "`readings`にはカタカナのみ追加することに注意してください。これは前方一致RK検索を使ってオートコンプリート候補の用語を検索するのに必要です。" + +msgid "" +"Then use [`&^~` operator][prefix-rk-search-v2] against `readings` for prefix R" +"K search. Here are some examples about prefix RK search." +msgstr "" +"`readings`に対して前方一致RK検索をするために[`&^~`演算子][prefix-rk-search-v2]を使います。前方一致RK検索の例をいく" +"つか示します。" + +msgid " * Prefix RK search with romaji" +msgstr " * ローマ字を使った前方一致RK検索" + +msgid " * Prefix RK search with hiragana" +msgstr " * ひらがなを使った前方一致RK検索" + +msgid " * Prefix RK search with katanaka" +msgstr " * カタカナを使った前方一致RK検索" + +msgid "" +"You can search \"牛乳\" as auto complete candidate of \"gyu\" (romaji) by prefix RK " +"search:" +msgstr "前方一致RK検索では「gyu」(ローマ字)で「牛乳」をオートコンプリート候補の用語として検索できます。" + +msgid "" +"```sql\n" +"SELECT term FROM terms WHERE readings &^~ 'gyu';\n" +"-- term \n" +"-- ------\n" +"-- 牛乳\n" +"-- (1 row)\n" +"```" +msgstr "" + +msgid "" +"You can search \"牛乳\" as auto complete candidate of ぎゅう\" (hiragana) by prefix RK" +" search:" +msgstr "前方一致RK検索では「ぎゅう」(ひらがな)で「牛乳」をオートコンプリート候補として検索できます。" + +msgid "" +"```sql\n" +"SELECT term FROM terms WHERE readings &^~ 'ぎゅう';\n" +"-- term \n" +"-- ------\n" +"-- 牛乳\n" +"-- (1 row)\n" +"```" +msgstr "" + +msgid "" +"You can search \"牛乳\" as auto complete candidate of \"ギュウ\" (katanaka) by prefix R" +"K search." +msgstr "前方一致RK検索では「ギュウ」(カタカナ)で「牛乳」をオートコンプリート候補の用語として検索できます。" + +msgid "" +"```sql\n" +"SELECT term FROM terms WHERE readings &^~ 'ギュウ';\n" +"-- term \n" +"-- ------\n" +"-- 牛乳\n" +"-- (1 row)\n" +"```" +msgstr "" + +msgid "" +"There is an advanced usage of `readings`. If reading of synonym is stored in `" +"readings`, you can also search as auto complete candidate term:" +msgstr "" +"より高度な`readings`の使い方があります。同義語の読みを`readings`に入れると、それを使ってオートコンプリート候補の用語を検索することもでき" +"ます。" + +msgid "" +"```sql\n" +"SELECT term FROM terms WHERE readings &^~ 'mi';\n" +"-- term \n" +"-- ------\n" +"-- 牛乳\n" +"-- (1 row)\n" +"```" +msgstr "" + +msgid "" +"\"ミルク\" is a synonym of \"牛乳\". You can search \"牛乳\" by \"mi\" as auto complete candi" +"date term because \"ミルク\" is stored in `readings` column." +msgstr "" +"「ミルク」は「牛乳」の同義語です。ヨミガナとして「ミルク」を`readings`に追加することで、「mi」で検索したときも「牛乳」をオートコンプリート候補の" +"用語として検索できます。" + +msgid "## Loose full text search" +msgstr "## 緩い全文検索" + +msgid "" +"Use [`&@`][match-v2] against `term` for loose full text search. Here is the re" +"sult of it:" +msgstr "緩い全文検索をするために`term`に対して[`&@`][match-v2]を使います。結果は次の通りです。" + +msgid "" +"```sql\n" +"SELECT term FROM terms WHERE term &@ 'mpl';\n" +"-- term \n" +"-- ---------------\n" +"-- auto-complete\n" +"-- (1 rows)\n" +"```" +msgstr "" + +msgid "" +"[groonga-prefix-rk-search]:http://groonga.org/docs/reference/operations/prefix" +"_rk_search.html" +msgstr "" +"[groonga-prefix-rk-search]:http://groonga.org/ja/docs/reference/operations/pre" +"fix_rk_search.html" + +msgid "[wikipedia-katakana]:https://en.wikipedia.org/wiki/Katakana" +msgstr "[wikipedia-katakana]:https://ja.wikipedia.org/wiki/%E7%89%87%E4%BB%AE%E5%90%8D" + +msgid "[wikipedia-romaji]:https://en.wikipedia.org/wiki/Romanization_of_Japanese" +msgstr "" +"[wikipedia-romaji]:https://ja.wikipedia.org/wiki/%E3%83%AD%E3%83%BC%E3%83%9E%E" +"5%AD%97" + +msgid "[wikipedia-hiragana]:https://en.wikipedia.org/wiki/Hiragana" +msgstr "[wikipedia-hiragana]:https://ja.wikipedia.org/wiki/%E5%B9%B3%E4%BB%AE%E5%90%8D" + +msgid "[prefix-search-v2]:../reference/operators/prefix-search-v2.html" +msgstr "" + +msgid "[match-v2]:../reference/operators/match-v2.html" +msgstr "" + +msgid "[prefix-rk-search-v2]:../reference/operators/prefix-rk-search-v2.html" +msgstr "" Deleted: _po/ja/how-to/autocomplete.po (+0 -234) 100644 =================================================================== --- _po/ja/how-to/autocomplete.po 2017-06-20 18:04:52 +0900 (9ac96f5) +++ /dev/null @@ -1,234 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: 2017-06-20 15:06+0900\n" -"Language: ja\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=1; plural=0;\n" - -msgid "" -"---\n" -"title: How to use auto complete feature\n" -"---" -msgstr "" -"---\n" -"title: PGroongaでオートコンプリートをする方法\n" -"---" - -msgid "# How to use auto complete feature with PGroonga" -msgstr "PGroongaでオートコンプリートをする方法" - -msgid "" -"PGroonga can't use Groonga's suggest plugin directly, so in this section, show" -"s you an alternative way to implement auto complete feature." -msgstr "" -"PGroongaはGroongaのサジェストプラグインを直接使うことができません。そのためこのハウツーではPGroongaでオートコンプリートを実現する代替" -"案を紹介します。" - -msgid "There are some way to implement auto complete feature with PGroonga" -msgstr "PGroongaでオートコンプリートを実装するにはいくつかやり方があります。" - -msgid "" -"* Use prefix search against auto complete candidate terms\n" -"* Use full text search against auto complete candidate terms\n" -"* Use romaji katakana search against auto complete candidate readings" -msgstr "" -"* オートコンプリート候補の用語に対して前方一致検索をする\n" -"* オートコンプリート候補の用語に対して全文検索をする\n" -"* オートコンプリート候補の用語の読みに対してローマ字カタカナ検索をする" - -msgid "You can use above methods in combination as you like." -msgstr "上記の方法を好きなように組み合わせて使うことができます。" - -msgid "## Sample schema and indexes" -msgstr "## サンプルのスキーマとインデックスの定義" - -msgid "Here is the sample schema." -msgstr "サンプルのスキーマを示します。" - -msgid "" -"```\n" -"CREATE TABLE terms (\n" -" term text,\n" -" readings text[]\n" -");\n" -"```" -msgstr "" - -msgid "" -"Auto complete candidate terms are stored into `term`. Readings of `term` are s" -"tored in `readings`. As you know, type of `readings` is `text[]`, multiple rea" -"dings are stored into `readings`." -msgstr "" -"オートコンプリートの候補となる用語は `term` に保存されます。 `term` の読みは `readings` へと保存されます。 `readings`" -" の型が `text[]` であることからわかるように、複数の読みが `readings` には保存できます。" - -msgid "Here is the sample index definition." -msgstr "サンプルのインデックス定義を示します。" - -msgid "" -"```\n" -"CREATE INDEX pgroonga_terms_prefix_search ON terms USING pgroonga\n" -" (term pgroonga.text_term_search_ops_v2,\n" -" readings pgroonga.text_array_term_search_ops_v2);\n" -"CREATE INDEX pgroonga_terms_full_text_search ON terms USING pgroonga\n" -" (term pgroonga.text_full_text_search_ops_v2);\n" -"```" -msgstr "" - -msgid "Above indexes are required for prefix search and full text search." -msgstr "上記のインデックス定義は前方一致検索や全文検索に必要です。" - -msgid "## Use prefix search against auto complete candidate terms" -msgstr "## オートコンプリート候補の用語に対して前方一致検索" - -msgid "" -"There is a simple way to provide auto complete feature. It is prefix search.\n" -"PGroonga provides operator for it: [`&^` operator][prefix-search-v2]" -msgstr "" -"オートコンプリート機能を提供するシンプルな方法です。前方一致を使います。PGroongaはそのための演算子として [`&^`演算子][prefix-sear" -"ch-v2]を提供しています。" - -msgid "Here is the sample data for prefix search." -msgstr "前方一致検索をするためのサンプルデータを示します。" - -msgid "" -"```\n" -"INSERT INTO terms (term) VALUES ('autocomplete');\n" -"```" -msgstr "" - -msgid "Then, use `&^` against `term` for prefix search. Here is the result of it." -msgstr "そして、前方一致検索するため `term` に対して `&^` を使います。結果は次の通りです。" - -msgid "" -"```\n" -"SELECT term FROM terms WHERE term &^ 'auto';\n" -"-- term \n" -"-- --------------\n" -"-- autocomplete\n" -"-- (1 rows)\n" -"```" -msgstr "" - -msgid "The result contains `autocomplete` as auto complete candidate term." -msgstr "結果には `autocomplete` がオートコンプリート候補の用語として含まれます。" - -msgid "## Use full text search against auto complete candidate terms" -msgstr "## オートコンプリート候補の用語に対して全文検索" - -msgid "Use `&@` against `term` for full text search. Here is the result of it." -msgstr "`term` を全文検索するには `&@` を使います。結果は次の通りです。" - -msgid "" -"```\n" -"SELECT term FROM terms WHERE term &@ 'comp';\n" -"-- term \n" -"-- --------------\n" -"-- autocomplete\n" -"-- (1 rows)\n" -"```" -msgstr "" - -msgid "## Use prefix romaji katakana search against auto complete candidate readings" -msgstr "## オートコンプリート候補の用語の読みに対してローマ字カタカナ前方一致検索" - -msgid "Here is the sample data for RK search." -msgstr "RK検索のためのサンプルデータを示します。" - -msgid "" -"```\n" -"INSERT INTO terms (term, readings) VALUES ('牛乳', ARRAY['ギュウニュウ', 'ミルク']);\n" -"```" -msgstr "" - -msgid "" -"Note that you need insert only katakana in `readings`. This is required to sea" -"rch auto complete candidate terms with prefix RK search." -msgstr "`readings` にはカタカナのみ追加することに注意してください。これは前方一致RK検索を使ってオートコンプリート候補の用語を検索するのに必要です。" - -msgid "" -"Then use `&^~` against `readings` for prefix RK search. Here are some examples" -" about prefix RK search." -msgstr "そして、 `term` に対して前方一致RK検索をするのに `&^~` を使います。前方一致RK検索の例を示します。" - -msgid "" -"* Prefix RK search with Hiragana\n" -"* Prefix RK search with Katanaka\n" -"* Prefix RK search with Romaji" -msgstr "" -"* 前方一致RK検索(ひらがな)\n" -"* 前方一致RK検索(カタカナ)\n" -"* 前方一致RK検索(ローマ字)" - -msgid "" -"```\n" -"SELECT term FROM terms WHERE readings &^~ 'ぎゅう';\n" -"-- term \n" -"-- ------\n" -"-- 牛乳\n" -"-- (1 row)\n" -"```" -msgstr "" - -msgid "" -"You can search \"牛乳\" as auto complete candidate of ぎゅう\" (Hiragana) by prefix RK" -" search." -msgstr "前方一致RK検索によって「ぎゅう」(ひらがな)から\"牛乳\"をオートコンプリート候補として検索することができました。" - -msgid "" -"```\n" -"SELECT term FROM terms WHERE readings &^~ 'ギュウ';\n" -"-- term \n" -"-- ------\n" -"-- 牛乳\n" -"-- (1 row)\n" -"```" -msgstr "" - -msgid "" -"You can also search \"牛乳\" as auto complete candidate of \"ギュウ\" (Katanaka) by pre" -"fix RK search." -msgstr "前方一致RK検索では「ギュウ」(カタカナ)で\"牛乳\"をオートコンプリート候補の用語として検索することもできます。" - -msgid "" -"```\n" -"SELECT term FROM terms WHERE readings &^~ 'gyu';\n" -"-- term \n" -"-- ------\n" -"-- 牛乳\n" -"-- (1 row)\n" -"```" -msgstr "" - -msgid "" -"You can also search \"牛乳\" as auto complete candidate of \"gyu\" (Romaji) by prefi" -"x RK search." -msgstr "前方一致RK検索では「gyu」(ローマ字)で\"牛乳\"をオートコンプリート候補の用語として検索することもできます。" - -msgid "" -"There is an advanced usage of `readings`. If reading of synonym is\n" -"stored in `readings`, you can also search as auto complete candidate\n" -"term." -msgstr "" -"より高度な `readings` の使い方があります。同義語の読みを `readings` に入れると、それを使ってオートコンプリート候補の用語を検索するこ" -"ともできます。" - -msgid "" -"```\n" -"SELECT term FROM terms WHERE readings &^~ 'mi';\n" -"-- term \n" -"-- ------\n" -"-- 牛乳\n" -"-- (1 row)\n" -"```" -msgstr "" - -msgid "" -"As the synonym of \"牛乳\" is \"ミルク\", so you can search it by 'mi' as auto complete" -" candidate term because \"ミルク\" is stored in `readings` column." -msgstr "" -"\"牛乳\"の同義語は\"ミルク\"ですが、\"ミルク\" を `readings` に読みとして追加することで、'mi'で検索したときも\"牛乳\"をオートコンプリート候" -"補の用語として検索できます。" Modified: _po/ja/how-to/index.po (+5 -5) =================================================================== --- _po/ja/how-to/index.po 2017-06-20 18:04:52 +0900 (eea0007) +++ _po/ja/how-to/index.po 2017-06-20 20:57:22 +0900 (aca0610) @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: 2017-06-20 15:03+0900\n" +"PO-Revision-Date: 2017-06-20 20:55+0900\n" "Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -31,11 +31,11 @@ msgstr "" "このページにない有用な情報を持っている場合は、ぜひ[pgroonga/pgroonga.github.io](https://github.com/pgro" "onga/pgroonga.github.io)にプルリクエストを送ってください。あなたの持っている有用な情報を共有してください!" -msgid "## How to use auto complete feature" -msgstr "## オートコンプリートする方法" +msgid "## How to implement auto complete feature" +msgstr "## オートコンプリートの実装方法" -msgid " * [How to use auto complete feature](autocomplete.html)" -msgstr " * [オートコンプリートする方法](autocomplete.html)" +msgid " * [How to implement auto complete feature](auto-complete.html)" +msgstr " * [オートコンプリートの実装方法](auto-complete.html)" msgid "## How to use PGroonga with Web application framework" msgstr "## Webアプリケーションフレームワークと一緒にPGroongaを使う方法" Added: how-to/auto-complete.md (+159 -0) 100644 =================================================================== --- /dev/null +++ how-to/auto-complete.md 2017-06-20 20:57:22 +0900 (a75a8e0) @@ -0,0 +1,159 @@ +--- +title: How to implement auto complete feature +--- + +# How to implement auto complete feature + +Auto complete is useful feature for easy to use search box. PGroonga has features to implement auto complete. + +You can implement auto complete by combining the following searches: + + * Prefix search + + * Only for Japanese: Prefix RK search for auto complete by readings + + * Loose full text search + +## Sample schema and indexes + +Here is the sample schema: + +```sql +CREATE TABLE terms ( + term text, + readings text[] +); +``` + +Auto complete candidate terms are stored into `term`. Readings of `term` are stored in `readings`. As you know, type of `readings` is `text[]`, multiple readings are stored into `readings`. + +Here is the sample index definition: + +```sql +CREATE INDEX pgroonga_terms_prefix_search ON terms USING pgroonga + (term pgroonga.text_term_search_ops_v2, + readings pgroonga.text_array_term_search_ops_v2); + +CREATE INDEX pgroonga_terms_full_text_search ON terms USING pgroonga + (term pgroonga.text_full_text_search_ops_v2) + WITH (tokenizer = 'TokenBigramSplitSymbolAlphaDigit'); +``` + +The above indexes are required for prefix search and full text search. + +`TokenBigramSplitSymbolAlphaDigit` tokenizer is suitable for loose full text search. + +## Prefix search + +There is a simple way to implement auto complete feature. It is prefix search. + +PGroonga provides operator for it: [`&^` operator][prefix-search-v2] + +Here is the sample data for prefix search: + +```sql +INSERT INTO terms (term) VALUES ('auto-complete'); +``` + +Then, use `&^` against `term` for prefix search. Here is the result of it: + +```sql +SELECT term FROM terms WHERE term &^ 'auto'; +-- term +-- --------------- +-- auto-complete +-- (1 rows) +``` + +The result contains `auto-complete` as auto complete candidate term. + +## Only for Japanese: Prefix RK search for auto complete by readings + +[Prefix RK search][groonga-prefix-rk-search] is a prefix search variant. It supports searching [katakana][wikipedia-katakana] by [romaji][wikipedia-romaji], [hiragana][wikipedia-hiragana] or katakana. It's useful for Japanese. + +Here is the sample data for prefix RK search: + +```sql +INSERT INTO terms (term, readings) VALUES ('牛乳', ARRAY['ギュウニュウ', 'ミルク']); +``` + +Note that you need insert only katakana in `readings`. This is required to search auto complete candidate terms with prefix RK search. + +Then use [`&^~` operator][prefix-rk-search-v2] against `readings` for prefix RK search. Here are some examples about prefix RK search. + + * Prefix RK search with romaji + + * Prefix RK search with hiragana + + * Prefix RK search with katanaka + +You can search "牛乳" as auto complete candidate of "gyu" (romaji) by prefix RK search: + +```sql +SELECT term FROM terms WHERE readings &^~ 'gyu'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +You can search "牛乳" as auto complete candidate of ぎゅう" (hiragana) by prefix RK search: + +```sql +SELECT term FROM terms WHERE readings &^~ 'ぎゅう'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +You can search "牛乳" as auto complete candidate of "ギュウ" (katanaka) by prefix RK search. + +```sql +SELECT term FROM terms WHERE readings &^~ 'ギュウ'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +There is an advanced usage of `readings`. If reading of synonym is stored in `readings`, you can also search as auto complete candidate term: + +```sql +SELECT term FROM terms WHERE readings &^~ 'mi'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +"ミルク" is a synonym of "牛乳". You can search "牛乳" by "mi" as auto complete candidate term because "ミルク" is stored in `readings` column. + +## Loose full text search + +Use [`&@`][match-v2] against `term` for loose full text search. Here is the result of it: + +```sql +SELECT term FROM terms WHERE term &@ 'mpl'; +-- term +-- --------------- +-- auto-complete +-- (1 rows) +``` + +The result contains `auto-complete` as auto complete candidate term. + + +[groonga-prefix-rk-search]:http://groonga.org/docs/reference/operations/prefix_rk_search.html + +[wikipedia-katakana]:https://en.wikipedia.org/wiki/Katakana + +[wikipedia-romaji]:https://en.wikipedia.org/wiki/Romanization_of_Japanese + +[wikipedia-hiragana]:https://en.wikipedia.org/wiki/Hiragana + +[prefix-search-v2]:../reference/operators/prefix-search-v2.html + +[match-v2]:../reference/operators/match-v2.html + +[prefix-rk-search-v2]:../reference/operators/prefix-rk-search-v2.html Deleted: how-to/autocomplete.md (+0 -137) 100644 =================================================================== --- how-to/autocomplete.md 2017-06-20 18:04:52 +0900 (82e1921) +++ /dev/null @@ -1,137 +0,0 @@ ---- -title: How to use auto complete feature ---- - -# How to use auto complete feature with PGroonga - -PGroonga can't use Groonga's suggest plugin directly, so in this section, shows you an alternative way to implement auto complete feature. - -There are some way to implement auto complete feature with PGroonga - -* Use prefix search against auto complete candidate terms -* Use full text search against auto complete candidate terms -* Use romaji katakana search against auto complete candidate readings - -You can use above methods in combination as you like. - -## Sample schema and indexes - -Here is the sample schema. - -``` -CREATE TABLE terms ( - term text, - readings text[] -); -``` - -Auto complete candidate terms are stored into `term`. Readings of `term` are stored in `readings`. As you know, type of `readings` is `text[]`, multiple readings are stored into `readings`. - -Here is the sample index definition. - -``` -CREATE INDEX pgroonga_terms_prefix_search ON terms USING pgroonga - (term pgroonga.text_term_search_ops_v2, - readings pgroonga.text_array_term_search_ops_v2); -CREATE INDEX pgroonga_terms_full_text_search ON terms USING pgroonga - (term pgroonga.text_full_text_search_ops_v2); -``` - -Above indexes are required for prefix search and full text search. - -## Use prefix search against auto complete candidate terms - -There is a simple way to provide auto complete feature. It is prefix search. -PGroonga provides operator for it: [`&^` operator][prefix-search-v2] - -Here is the sample data for prefix search. - -``` -INSERT INTO terms (term) VALUES ('autocomplete'); -``` - -Then, use `&^` against `term` for prefix search. Here is the result of it. - -``` -SELECT term FROM terms WHERE term &^ 'auto'; --- term --- -------------- --- autocomplete --- (1 rows) -``` - -The result contains `autocomplete` as auto complete candidate term. - -## Use full text search against auto complete candidate terms - -Use `&@` against `term` for full text search. Here is the result of it. - -``` -SELECT term FROM terms WHERE term &@ 'comp'; --- term --- -------------- --- autocomplete --- (1 rows) -``` - -The result contains `autocomplete` as auto complete candidate term. - -## Use prefix romaji katakana search against auto complete candidate readings - -Here is the sample data for RK search. - -``` -INSERT INTO terms (term, readings) VALUES ('牛乳', ARRAY['ギュウニュウ', 'ミルク']); -``` - -Note that you need insert only katakana in `readings`. This is required to search auto complete candidate terms with prefix RK search. - -Then use `&^~` against `readings` for prefix RK search. Here are some examples about prefix RK search. - -* Prefix RK search with Hiragana -* Prefix RK search with Katanaka -* Prefix RK search with Romaji - -``` -SELECT term FROM terms WHERE readings &^~ 'ぎゅう'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -You can search "牛乳" as auto complete candidate of ぎゅう" (Hiragana) by prefix RK search. - -``` -SELECT term FROM terms WHERE readings &^~ 'ギュウ'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -You can also search "牛乳" as auto complete candidate of "ギュウ" (Katanaka) by prefix RK search. - -``` -SELECT term FROM terms WHERE readings &^~ 'gyu'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -You can also search "牛乳" as auto complete candidate of "gyu" (Romaji) by prefix RK search. - -There is an advanced usage of `readings`. If reading of synonym is -stored in `readings`, you can also search as auto complete candidate -term. - -``` -SELECT term FROM terms WHERE readings &^~ 'mi'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -As the synonym of "牛乳" is "ミルク", so you can search it by 'mi' as auto complete candidate term because "ミルク" is stored in `readings` column. Modified: how-to/index.md (+2 -2) =================================================================== --- how-to/index.md 2017-06-20 18:04:52 +0900 (62eb13f) +++ how-to/index.md 2017-06-20 20:57:22 +0900 (835de00) @@ -8,9 +8,9 @@ This document describes about useful information for specific situations. If you have useful information that isn't listed in this page, please send a pull request to [pgroonga/pgroonga.github.io](https://github.com/pgroonga/pgroonga.github.io). Please share your useful information! -## How to use auto complete feature +## How to implement auto complete feature - * [How to use auto complete feature](autocomplete.html) + * [How to implement auto complete feature](auto-complete.html) ## How to use PGroonga with Web application framework Added: ja/how-to/auto-complete.md (+159 -0) 100644 =================================================================== --- /dev/null +++ ja/how-to/auto-complete.md 2017-06-20 20:57:22 +0900 (e5927f8) @@ -0,0 +1,159 @@ +--- +title: オートコンプリートの実装方法 +--- + +# オートコンプリート機能の実装方法 + +オートコンプリートは使いやすい検索ボックスを作るのに便利な機能です。Pgroongaにはオートコンプリートを実装するための機能があります。 + +次の検索を組み合わせることでオートコンプリートを実現できます。 + + * 前方一致検索 + + * 日本語のみ:ヨミガナでのオートコンプリート用に前方一致RK検索 + + * 緩い全文検索 + +## サンプルスキーマとインデックス + +サンプルのスキーマを示します。 + +```sql +CREATE TABLE terms ( + term text, + readings text[] +); +``` + +オートコンプリート候補の用語は`term`に保存します。`term`のヨミガナは`readings`に保存します。`readings`の型が`text[]`であることからわかるように、`readings`には複数のヨミガナを保存できます。 + +サンプルのインデックス定義を示します。 + +```sql +CREATE INDEX pgroonga_terms_prefix_search ON terms USING pgroonga + (term pgroonga.text_term_search_ops_v2, + readings pgroonga.text_array_term_search_ops_v2); + +CREATE INDEX pgroonga_terms_full_text_search ON terms USING pgroonga + (term pgroonga.text_full_text_search_ops_v2) + WITH (tokenizer = 'TokenBigramSplitSymbolAlphaDigit'); +``` + +上記のインデックス定義は前方一致検索と全文検索に必要です。 + +`TokenBigramSplitSymbolAlphaDigit`トークナイザーは緩い全文検索に向いています。 + +## 前方一致検索 + +オートコンプリート機能を実現するシンプルな方法は前方一致検索を使う方法です。 + +PGroongaは前方一致検索用の演算子として[`&^`演算子][prefix-search-v2]を提供しています。 + +前方一致検索をするためのサンプルデータを示します。 + +```sql +INSERT INTO terms (term) VALUES ('auto-complete'); +``` + +データを挿入したら、`term`に対して`&^`を使って前方一致検索をします。結果は次の通りです。 + +```sql +SELECT term FROM terms WHERE term &^ 'auto'; +-- term +-- --------------- +-- auto-complete +-- (1 rows) +``` + +オートコンプリート候補の用語として`auto-complete`がヒットしています。 + +## 日本語のみ:ヨミガナでのオートコンプリート用に前方一致RK検索 + +[前方一致RK検索][groonga-prefix-rk-search]は前方一致検索の一種です。これは[ローマ字][wikipedia-romaji]、[ひらがな][wikipedia-hiragana]またはカタカナで[カタカナ][wikipedia-katakana]を検索できます。日本語にはとても便利な機能です。 + +前方一致RK検索のためのサンプルデータを示します。 + +```sql +INSERT INTO terms (term, readings) VALUES ('牛乳', ARRAY['ギュウニュウ', 'ミルク']); +``` + +`readings`にはカタカナのみ追加することに注意してください。これは前方一致RK検索を使ってオートコンプリート候補の用語を検索するのに必要です。 + +`readings`に対して前方一致RK検索をするために[`&^~`演算子][prefix-rk-search-v2]を使います。前方一致RK検索の例をいくつか示します。 + + * ローマ字を使った前方一致RK検索 + + * ひらがなを使った前方一致RK検索 + + * カタカナを使った前方一致RK検索 + +前方一致RK検索では「gyu」(ローマ字)で「牛乳」をオートコンプリート候補の用語として検索できます。 + +```sql +SELECT term FROM terms WHERE readings &^~ 'gyu'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +前方一致RK検索では「ぎゅう」(ひらがな)で「牛乳」をオートコンプリート候補として検索できます。 + +```sql +SELECT term FROM terms WHERE readings &^~ 'ぎゅう'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +前方一致RK検索では「ギュウ」(カタカナ)で「牛乳」をオートコンプリート候補の用語として検索できます。 + +```sql +SELECT term FROM terms WHERE readings &^~ 'ギュウ'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +より高度な`readings`の使い方があります。同義語の読みを`readings`に入れると、それを使ってオートコンプリート候補の用語を検索することもできます。 + +```sql +SELECT term FROM terms WHERE readings &^~ 'mi'; +-- term +-- ------ +-- 牛乳 +-- (1 row) +``` + +「ミルク」は「牛乳」の同義語です。ヨミガナとして「ミルク」を`readings`に追加することで、「mi」で検索したときも「牛乳」をオートコンプリート候補の用語として検索できます。 + +## 緩い全文検索 + +緩い全文検索をするために`term`に対して[`&@`][match-v2]を使います。結果は次の通りです。 + +```sql +SELECT term FROM terms WHERE term &@ 'mpl'; +-- term +-- --------------- +-- auto-complete +-- (1 rows) +``` + +オートコンプリート候補の用語として`auto-complete`がヒットしています。 + + +[groonga-prefix-rk-search]:http://groonga.org/ja/docs/reference/operations/prefix_rk_search.html + +[wikipedia-katakana]:https://ja.wikipedia.org/wiki/%E7%89%87%E4%BB%AE%E5%90%8D + +[wikipedia-romaji]:https://ja.wikipedia.org/wiki/%E3%83%AD%E3%83%BC%E3%83%9E%E5%AD%97 + +[wikipedia-hiragana]:https://ja.wikipedia.org/wiki/%E5%B9%B3%E4%BB%AE%E5%90%8D + +[prefix-search-v2]:../reference/operators/prefix-search-v2.html + +[match-v2]:../reference/operators/match-v2.html + +[prefix-rk-search-v2]:../reference/operators/prefix-rk-search-v2.html Deleted: ja/how-to/autocomplete.md (+0 -134) 100644 =================================================================== --- ja/how-to/autocomplete.md 2017-06-20 18:04:52 +0900 (632e563) +++ /dev/null @@ -1,134 +0,0 @@ ---- -title: PGroongaでオートコンプリートをする方法 ---- - -PGroongaでオートコンプリートをする方法 - -PGroongaはGroongaのサジェストプラグインを直接使うことができません。そのためこのハウツーではPGroongaでオートコンプリートを実現する代替案を紹介します。 - -PGroongaでオートコンプリートを実装するにはいくつかやり方があります。 - -* オートコンプリート候補の用語に対して前方一致検索をする -* オートコンプリート候補の用語に対して全文検索をする -* オートコンプリート候補の用語の読みに対してローマ字カタカナ検索をする - -上記の方法を好きなように組み合わせて使うことができます。 - -## サンプルのスキーマとインデックスの定義 - -サンプルのスキーマを示します。 - -``` -CREATE TABLE terms ( - term text, - readings text[] -); -``` - -オートコンプリートの候補となる用語は `term` に保存されます。 `term` の読みは `readings` へと保存されます。 `readings` の型が `text[]` であることからわかるように、複数の読みが `readings` には保存できます。 - -サンプルのインデックス定義を示します。 - -``` -CREATE INDEX pgroonga_terms_prefix_search ON terms USING pgroonga - (term pgroonga.text_term_search_ops_v2, - readings pgroonga.text_array_term_search_ops_v2); -CREATE INDEX pgroonga_terms_full_text_search ON terms USING pgroonga - (term pgroonga.text_full_text_search_ops_v2); -``` - -上記のインデックス定義は前方一致検索や全文検索に必要です。 - -## オートコンプリート候補の用語に対して前方一致検索 - -オートコンプリート機能を提供するシンプルな方法です。前方一致を使います。PGroongaはそのための演算子として [`&^`演算子][prefix-search-v2]を提供しています。 - -前方一致検索をするためのサンプルデータを示します。 - -``` -INSERT INTO terms (term) VALUES ('autocomplete'); -``` - -そして、前方一致検索するため `term` に対して `&^` を使います。結果は次の通りです。 - -``` -SELECT term FROM terms WHERE term &^ 'auto'; --- term --- -------------- --- autocomplete --- (1 rows) -``` - -結果には `autocomplete` がオートコンプリート候補の用語として含まれます。 - -## オートコンプリート候補の用語に対して全文検索 - -`term` を全文検索するには `&@` を使います。結果は次の通りです。 - -``` -SELECT term FROM terms WHERE term &@ 'comp'; --- term --- -------------- --- autocomplete --- (1 rows) -``` - -結果には `autocomplete` がオートコンプリート候補の用語として含まれます。 - -## オートコンプリート候補の用語の読みに対してローマ字カタカナ前方一致検索 - -RK検索のためのサンプルデータを示します。 - -``` -INSERT INTO terms (term, readings) VALUES ('牛乳', ARRAY['ギュウニュウ', 'ミルク']); -``` - -`readings` にはカタカナのみ追加することに注意してください。これは前方一致RK検索を使ってオートコンプリート候補の用語を検索するのに必要です。 - -そして、 `term` に対して前方一致RK検索をするのに `&^~` を使います。前方一致RK検索の例を示します。 - -* 前方一致RK検索(ひらがな) -* 前方一致RK検索(カタカナ) -* 前方一致RK検索(ローマ字) - -``` -SELECT term FROM terms WHERE readings &^~ 'ぎゅう'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -前方一致RK検索によって「ぎゅう」(ひらがな)から"牛乳"をオートコンプリート候補として検索することができました。 - -``` -SELECT term FROM terms WHERE readings &^~ 'ギュウ'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -前方一致RK検索では「ギュウ」(カタカナ)で"牛乳"をオートコンプリート候補の用語として検索することもできます。 - -``` -SELECT term FROM terms WHERE readings &^~ 'gyu'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -前方一致RK検索では「gyu」(ローマ字)で"牛乳"をオートコンプリート候補の用語として検索することもできます。 - -より高度な `readings` の使い方があります。同義語の読みを `readings` に入れると、それを使ってオートコンプリート候補の用語を検索することもできます。 - -``` -SELECT term FROM terms WHERE readings &^~ 'mi'; --- term --- ------ --- 牛乳 --- (1 row) -``` - -"牛乳"の同義語は"ミルク"ですが、"ミルク" を `readings` に読みとして追加することで、'mi'で検索したときも"牛乳"をオートコンプリート候補の用語として検索できます。 Modified: ja/how-to/index.md (+2 -2) =================================================================== --- ja/how-to/index.md 2017-06-20 18:04:52 +0900 (d3b2a67) +++ ja/how-to/index.md 2017-06-20 20:57:22 +0900 (ab6fc73) @@ -8,9 +8,9 @@ title: ハウツー このページにない有用な情報を持っている場合は、ぜひ[pgroonga/pgroonga.github.io](https://github.com/pgroonga/pgroonga.github.io)にプルリクエストを送ってください。あなたの持っている有用な情報を共有してください! -## オートコンプリートする方法 +## オートコンプリートの実装方法 - * [オートコンプリートする方法](autocomplete.html) + * [オートコンプリートの実装方法](auto-complete.html) ## Webアプリケーションフレームワークと一緒にPGroongaを使う方法 -------------- next part -------------- HTML����������������������������... 下載