Kouhei Sutou
null+****@clear*****
Mon Jul 3 11:25:59 JST 2017
Kouhei Sutou 2017-07-03 11:25:59 +0900 (Mon, 03 Jul 2017) New Revision: abafa7d8d9931cffa675bca6760c53b06287d57c https://github.com/pgroonga/pgroonga.github.io/commit/abafa7d8d9931cffa675bca6760c53b06287d57c Message: Document pgroonga.query_expand() Added files: _po/ja/reference/functions/pgroonga-query-expand.po ja/reference/functions/pgroonga-query-expand.md reference/functions/pgroonga-query-expand.md Modified files: _po/ja/reference/index.po ja/reference/index.md reference/index.md Added: _po/ja/reference/functions/pgroonga-query-expand.po (+201 -0) 100644 =================================================================== --- /dev/null +++ _po/ja/reference/functions/pgroonga-query-expand.po 2017-07-03 11:25:59 +0900 (2ffcb28) @@ -0,0 +1,201 @@ +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"PO-Revision-Date: 2017-07-03 11:24+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: pgroonga.query_expand function\n" +"upper_level: ../\n" +"---" +msgstr "" +"---\n" +"title: pgroonga.query_expand関数\n" +"upper_level: ../\n" +"---" + +msgid "# `pgroonga.query_expand` function" +msgstr "# `pgroonga.query_expand`関数" + +msgid "Since 1.2.2." +msgstr "1.2.2で追加。" + +msgid "## Summary" +msgstr "## 概要" + +msgid "" +"`pgroonga.query_expand` function expands registered synonyms in query in [quer" +"y syntax][groonga-query-syntax]. Query syntax is used by [`&@*` operator][quer" +"y-v2], [`&@*|` operator][query-in-v2] and so on." +msgstr "" +"`pgroonga.query_expand`関数は[クエリー構文][groonga-query-syntax]を使ったクエリー内にある登録済みの同義語を展" +"開します。クエリー構文は[`&@*`演算子][query-v2]や[`&@*|`演算子][query-in-v2]で使われています。" + +msgid "" +"`pgroonga.query_expand` function is useful to implement [query expansion][wiki" +"pedia-query-expansion]. See also [document for Groonga's query expansion featu" +"re][groonga-query-expander]." +msgstr "" +"`pgroonga.query_expand`関数は[クエリー展開][wikipedia-query-expansion]機能を実現するときに便利です。[G" +"roongaのクエリー展開機能のドキュメント][groonga-query-expander]も参照してください。" + +msgid "## Syntax" +msgstr "## 構文" + +msgid "Here is the syntax of this function:" +msgstr "この関数の構文は次の通りです。" + +msgid "" +"```text\n" +"text pgroonga.query_expansion(table_name,\n" +" term_column_name,\n" +" synonyms_column_name,\n" +" query)\n" +"```" +msgstr "" + +msgid "" +"`table_name` is a `text` type value. It's an existing table name that stores s" +"ynonyms." +msgstr "`table_name`は`text`型の値です。同義語を格納している既存のテーブルの名前を指定します。" + +msgid "" +"`term_column_name` is a `text` type value. It's an column name that stores ter" +"m to be expanded in the `table_name` table. The column is `text` type value." +msgstr "" +"`term_column_name`は`text`型の値です。`table_name`テーブル内の展開対象の単語を格納しているカラムの名前を指定します。この" +"カラムは`text`型のカラムです。" + +msgid "" +"`synonyms_column_name` is a `text` type value. It's an column name that stores" +" synonyms of the `term` column. The column is `text[]` type value." +msgstr "" +"`synonyms_column_name`は`text`型の値です。`term`カラムの同義語を格納しているカラム名を指定します。このカラムは`text[" +"]`型のカラムです。" + +msgid "" +"`query` is a `text` type value. It's a query that uses [query syntax][groonga-" +"query-syntax]." +msgstr "`query`は`text`型の値です。[クエリー構文][groonga-query-syntax]を使っているクエリーです。" + +msgid "" +"`pgroonga.query_expand` returns a `text` type value. All registered synonyms a" +"re expanded in the `query`." +msgstr "`pgroonga.query_expand`は`text`型の値を返します。`query`中にある登録済みの同義語がすべて展開されています。" + +msgid "" +"It's recommended that `${table_name}.${term_column_name}` is indexed by PGroon" +"ga with `pgroonga.text_term_search_ops_v2` operator class for fast query expan" +"sion like the following:" +msgstr "" +"次のように`pgroonga.text_term_search_ops_v2`演算子クラス指定のPGroongaで`${table_name}.${term" +"_column_name}`のインデックスを作成することをオススメします。これは高速にクエリー展開できるようにするためです。" + +msgid "" +"```sql\n" +"CREATE TABLE synonyms (\n" +" term text,\n" +" synonyms text[]\n" +");" +msgstr "" + +msgid "" +"CREATE INDEX synonyms_term\n" +" ON synonyms\n" +" USING pgroonga (term pgroonga.text_term_search_ops_v2);\n" +"```" +msgstr "" + +msgid "" +"`pgroonga.query_escape` function can work without index but can work faster wi" +"th index." +msgstr "`pgroonga.query_escape`関数はインデックスなしでも動きますが、インデックスがあるとより高速に動きます。" + +msgid "" +"You can use all index access methods that support `=` for `text` type such as " +"`btree`. But it's recommended that you use PGroonga. Because PGroonga supports" +" value normalized `=` (including case insensitive comparison) for `text`. Valu" +"e normalized `=` is useful for query expansion." +msgstr "" +"`btree`のように`text`型の`=`に対応しているインデックスアクセスメソッドであればどのインデックスアクセスメソッドでも使えます。しかし、PGro" +"ongaを使うことをオススメします。なぜなら、PGroongaは`text`の値を正規化した`=`(大文字小文字を無視した比較を含む)に対応しているからです" +"。クエリー展開時は値を正規化した`=`が有用です。" + +msgid "## Usage" +msgstr "## 使い方" + +msgid "Here are sample schema and data:" +msgstr "サンプルスキーマとデータは次の通りです。" + +msgid "" +"CREATE INDEX synonyms_term\n" +" ON synonyms\n" +" USING pgroonga (term pgroonga.text_term_search_ops_v2);" +msgstr "" + +msgid "" +"INSERT INTO synonyms VALUES ('PGroonga', ARRAY['PGroonga', 'Groonga PostgreSQL" +"']);\n" +"```" +msgstr "" + +msgid "" +"In this sample, all of `\"PGroonga\"` and `\"pgroonga\"` in query are expanded bec" +"ause PGroonga index is used:" +msgstr "このサンプルではPGroongaインデックスを使っているのでクエリー中の`\"PGroonga\"`も`\"pgroonga\"`もすべて展開されます。" + +msgid "" +"```sql\n" +"SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms',\n" +" 'PGroonga OR Mroonga');\n" +"-- query_expand \n" +"-- -------------------------------------------------\n" +"-- ((PGroonga) OR (Groonga PostgreSQL)) OR Mroonga\n" +"-- (1 row)\n" +"SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms',\n" +" 'pgroonga OR mroonga');\n" +"-- query_expand \n" +"-- -------------------------------------------------\n" +"-- ((PGroonga) OR (Groonga PostgreSQL)) OR mroonga\n" +"-- (1 row)\n" +"```" +msgstr "" + +msgid "## See also" +msgstr "## 参考" + +msgid " * [`&@*` operator][query-v2]: Full text search by easy to use query language" +msgstr "" + +msgid "" +" * [`&?|` operator][query-in-v2]: Full text search by an array of queries in " +"easy to use query language" +msgstr " * [`&?|`演算子][query-in-v2]:便利なクエリー言語を使ったクエリーの配列での全文検索" + +msgid "" +"[groonga-query-syntax]:http://groonga.org/docs/reference/grn_expr/query_syntax" +".html" +msgstr "" +"[groonga-query-syntax]:http://groonga.org/ja/docs/reference/grn_expr/query_syn" +"tax.html" + +msgid "" +"[groonga-query-expander]:http://groonga.org/docs/reference/commands/select.htm" +"l#select-query-expander" +msgstr "" +"[groonga-query-expander]:http://groonga.org/ja/docs/reference/commands/select." +"html#select-query-expander" + +msgid "[wikipedia-query-expansion]:https://en.wikipedia.org/wiki/Query_expansion" +msgstr "" + +msgid "[query-v2]:../operators/query-v2.html" +msgstr "" + +msgid "[query-in-v2]:../operators/query-in-v2.html" +msgstr "" Modified: _po/ja/reference/index.po (+7 -1) =================================================================== --- _po/ja/reference/index.po 2017-07-01 13:51:58 +0900 (7b41cc8) +++ _po/ja/reference/index.po 2017-07-03 11:25:59 +0900 (4da68d1) @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"PO-Revision-Date: 2017-07-01 13:51+0900\n" +"PO-Revision-Date: 2017-07-03 11:25+0900\n" "Language: ja\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -434,6 +434,9 @@ msgstr " * [`pgroonga.snippet_html`関数](functions/pgroonga-snippet-html.html msgid " * [`pgroonga.table_name` function](functions/pgroonga-table-name.html)" msgstr " * [`pgroonga.table_name`関数](functions/pgroonga-table-name.html)" +msgid " * [`pgroonga.query_expand` function][query-expand]" +msgstr " * [`pgroonga.query_expand`関数][query-expand]" + msgid "## Parameters" msgstr "## パラメーター" @@ -542,3 +545,6 @@ msgstr "" msgid "[upgrade-incompatible]:../upgrade/#incompatible-case" msgstr "" + +msgid "[query-expand]:functions/pgroonga-query-expand.html" +msgstr "" Added: ja/reference/functions/pgroonga-query-expand.md (+102 -0) 100644 =================================================================== --- /dev/null +++ ja/reference/functions/pgroonga-query-expand.md 2017-07-03 11:25:59 +0900 (e699a12) @@ -0,0 +1,102 @@ +--- +title: pgroonga.query_expand関数 +upper_level: ../ +--- + +# `pgroonga.query_expand`関数 + +1.2.2で追加。 + +## 概要 + +`pgroonga.query_expand`関数は[クエリー構文][groonga-query-syntax]を使ったクエリー内にある登録済みの同義語を展開します。クエリー構文は[`&@*`演算子][query-v2]や[`&@*|`演算子][query-in-v2]で使われています。 + +`pgroonga.query_expand`関数は[クエリー展開][wikipedia-query-expansion]機能を実現するときに便利です。[Groongaのクエリー展開機能のドキュメント][groonga-query-expander]も参照してください。 + +## 構文 + +この関数の構文は次の通りです。 + +```text +text pgroonga.query_expansion(table_name, + term_column_name, + synonyms_column_name, + query) +``` + +`table_name`は`text`型の値です。同義語を格納している既存のテーブルの名前を指定します。 + +`term_column_name`は`text`型の値です。`table_name`テーブル内の展開対象の単語を格納しているカラムの名前を指定します。このカラムは`text`型のカラムです。 + +`synonyms_column_name`は`text`型の値です。`term`カラムの同義語を格納しているカラム名を指定します。このカラムは`text[]`型のカラムです。 + +`query`は`text`型の値です。[クエリー構文][groonga-query-syntax]を使っているクエリーです。 + +`pgroonga.query_expand`は`text`型の値を返します。`query`中にある登録済みの同義語がすべて展開されています。 + +次のように`pgroonga.text_term_search_ops_v2`演算子クラス指定のPGroongaで`${table_name}.${term_column_name}`のインデックスを作成することをオススメします。これは高速にクエリー展開できるようにするためです。 + +```sql +CREATE TABLE synonyms ( + term text, + synonyms text[] +); + +CREATE INDEX synonyms_term + ON synonyms + USING pgroonga (term pgroonga.text_term_search_ops_v2); +``` + +`pgroonga.query_escape`関数はインデックスなしでも動きますが、インデックスがあるとより高速に動きます。 + +`btree`のように`text`型の`=`に対応しているインデックスアクセスメソッドであればどのインデックスアクセスメソッドでも使えます。しかし、PGroongaを使うことをオススメします。なぜなら、PGroongaは`text`の値を正規化した`=`(大文字小文字を無視した比較を含む)に対応しているからです。クエリー展開時は値を正規化した`=`が有用です。 + +## 使い方 + +サンプルスキーマとデータは次の通りです。 + +```sql +CREATE TABLE synonyms ( + term text, + synonyms text[] +); + +CREATE INDEX synonyms_term + ON synonyms + USING pgroonga (term pgroonga.text_term_search_ops_v2); + +INSERT INTO synonyms VALUES ('PGroonga', ARRAY['PGroonga', 'Groonga PostgreSQL']); +``` + +このサンプルではPGroongaインデックスを使っているのでクエリー中の`"PGroonga"`も`"pgroonga"`もすべて展開されます。 + +```sql +SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms', + 'PGroonga OR Mroonga'); +-- query_expand +-- ------------------------------------------------- +-- ((PGroonga) OR (Groonga PostgreSQL)) OR Mroonga +-- (1 row) +SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms', + 'pgroonga OR mroonga'); +-- query_expand +-- ------------------------------------------------- +-- ((PGroonga) OR (Groonga PostgreSQL)) OR mroonga +-- (1 row) +``` + +## 参考 + + * [`&@*` operator][query-v2]: Full text search by easy to use query language + + * [`&?|`演算子][query-in-v2]:便利なクエリー言語を使ったクエリーの配列での全文検索 + +[groonga-query-syntax]:http://groonga.org/ja/docs/reference/grn_expr/query_syntax.html + +[groonga-query-expander]:http://groonga.org/ja/docs/reference/commands/select.html#select-query-expander + +[wikipedia-query-expansion]:https://en.wikipedia.org/wiki/Query_expansion + +[query-v2]:../operators/query-v2.html + +[query-in-v2]:../operators/query-in-v2.html Modified: ja/reference/index.md (+4 -0) =================================================================== --- ja/reference/index.md 2017-07-01 13:51:58 +0900 (4175fd0) +++ ja/reference/index.md 2017-07-03 11:25:59 +0900 (6d40685) @@ -384,6 +384,8 @@ PGroonga 1.Y.Zは`pgroonga.XXX_v2`という演算子クラスを提供します * [`pgroonga.table_name`関数](functions/pgroonga-table-name.html) + * [`pgroonga.query_expand`関数][query-expand] + ## パラメーター * [`pgroonga.enable_wal`パラメーター](parameters/enable-wal.html) @@ -447,3 +449,5 @@ PGroonga 1.Y.Zは`pgroonga.XXX_v2`という演算子クラスを提供します [contain-jsonb]:operators/contain-jsonb.html [upgrade-incompatible]:../upgrade/#incompatible-case + +[query-expand]:functions/pgroonga-query-expand.html Added: reference/functions/pgroonga-query-expand.md (+102 -0) 100644 =================================================================== --- /dev/null +++ reference/functions/pgroonga-query-expand.md 2017-07-03 11:25:59 +0900 (b1d2ef7) @@ -0,0 +1,102 @@ +--- +title: pgroonga.query_expand function +upper_level: ../ +--- + +# `pgroonga.query_expand` function + +Since 1.2.2. + +## Summary + +`pgroonga.query_expand` function expands registered synonyms in query in [query syntax][groonga-query-syntax]. Query syntax is used by [`&@*` operator][query-v2], [`&@*|` operator][query-in-v2] and so on. + +`pgroonga.query_expand` function is useful to implement [query expansion][wikipedia-query-expansion]. See also [document for Groonga's query expansion feature][groonga-query-expander]. + +## Syntax + +Here is the syntax of this function: + +```text +text pgroonga.query_expansion(table_name, + term_column_name, + synonyms_column_name, + query) +``` + +`table_name` is a `text` type value. It's an existing table name that stores synonyms. + +`term_column_name` is a `text` type value. It's an column name that stores term to be expanded in the `table_name` table. The column is `text` type value. + +`synonyms_column_name` is a `text` type value. It's an column name that stores synonyms of the `term` column. The column is `text[]` type value. + +`query` is a `text` type value. It's a query that uses [query syntax][groonga-query-syntax]. + +`pgroonga.query_expand` returns a `text` type value. All registered synonyms are expanded in the `query`. + +It's recommended that `${table_name}.${term_column_name}` is indexed by PGroonga with `pgroonga.text_term_search_ops_v2` operator class for fast query expansion like the following: + +```sql +CREATE TABLE synonyms ( + term text, + synonyms text[] +); + +CREATE INDEX synonyms_term + ON synonyms + USING pgroonga (term pgroonga.text_term_search_ops_v2); +``` + +`pgroonga.query_escape` function can work without index but can work faster with index. + +You can use all index access methods that support `=` for `text` type such as `btree`. But it's recommended that you use PGroonga. Because PGroonga supports value normalized `=` (including case insensitive comparison) for `text`. Value normalized `=` is useful for query expansion. + +## Usage + +Here are sample schema and data: + +```sql +CREATE TABLE synonyms ( + term text, + synonyms text[] +); + +CREATE INDEX synonyms_term + ON synonyms + USING pgroonga (term pgroonga.text_term_search_ops_v2); + +INSERT INTO synonyms VALUES ('PGroonga', ARRAY['PGroonga', 'Groonga PostgreSQL']); +``` + +In this sample, all of `"PGroonga"` and `"pgroonga"` in query are expanded because PGroonga index is used: + +```sql +SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms', + 'PGroonga OR Mroonga'); +-- query_expand +-- ------------------------------------------------- +-- ((PGroonga) OR (Groonga PostgreSQL)) OR Mroonga +-- (1 row) +SELECT pgroonga.query_expand('synonyms', 'term', 'synonyms', + 'pgroonga OR mroonga'); +-- query_expand +-- ------------------------------------------------- +-- ((PGroonga) OR (Groonga PostgreSQL)) OR mroonga +-- (1 row) +``` + +## See also + + * [`&@*` operator][query-v2]: Full text search by easy to use query language + + * [`&?|` operator][query-in-v2]: Full text search by an array of queries in easy to use query language + +[groonga-query-syntax]:http://groonga.org/docs/reference/grn_expr/query_syntax.html + +[groonga-query-expander]:http://groonga.org/docs/reference/commands/select.html#select-query-expander + +[wikipedia-query-expansion]:https://en.wikipedia.org/wiki/Query_expansion + +[query-v2]:../operators/query-v2.html + +[query-in-v2]:../operators/query-in-v2.html Modified: reference/index.md (+4 -0) =================================================================== --- reference/index.md 2017-07-01 13:51:58 +0900 (a642c4a) +++ reference/index.md 2017-07-03 11:25:59 +0900 (f7f82c5) @@ -384,6 +384,8 @@ If you use them, you need to use [incompatible case steps][upgrade-incompatible] * [`pgroonga.table_name` function](functions/pgroonga-table-name.html) + * [`pgroonga.query_expand` function][query-expand] + ## Parameters * [`pgroonga.enable_wal` parameter](parameters/enable-wal.html) @@ -446,3 +448,5 @@ But you need to tune PGroonga in some cases such as a case that you need to hand [contain-jsonb]:operators/contain-jsonb.html [upgrade-incompatible]:../upgrade/#incompatible-case + +[query-expand]:functions/pgroonga-query-expand.html -------------- next part -------------- HTML����������������������������...Download