Kouhei Sutou
null+****@clear*****
Tue Mar 19 19:05:18 JST 2013
Kouhei Sutou 2013-03-19 19:05:18 +0900 (Tue, 19 Mar 2013) New Revision: a0b6d964ef41f85bb825928813a67533da3d4663 https://github.com/groonga/groonga/commit/a0b6d964ef41f85bb825928813a67533da3d4663 Message: Revert "doc: update for renaming --query_expansion to --query_expander" This reverts commit 4837201f9fd01826c4dd21ced2b3f357a9e9bfcd. I forgot to add renamed files. Sorry... Added files: doc/source/example/reference/commands/select/query_expansion_complex.log doc/source/example/reference/commands/select/query_expansion_substitute.log doc/source/example/reference/commands/select/query_expansion_substitution_table.log Modified files: doc/files.am doc/source/example/tutorial/query_expansion-3.log doc/source/reference/commands/select.txt doc/source/tutorial/query_expansion.txt Modified: doc/files.am (+6 -6) =================================================================== --- doc/files.am 2013-03-19 19:01:02 +0900 (098e0de) +++ doc/files.am 2013-03-19 19:05:18 +0900 (1b5e45c) @@ -38,9 +38,9 @@ absolute_source_files = \ $(top_srcdir)/doc/source/example/reference/commands/select/paging.log \ $(top_srcdir)/doc/source/example/reference/commands/select/query_and.log \ $(top_srcdir)/doc/source/example/reference/commands/select/query_equal.log \ - $(top_srcdir)/doc/source/example/reference/commands/select/query_expander_complex.log \ - $(top_srcdir)/doc/source/example/reference/commands/select/query_expander_substitute.log \ - $(top_srcdir)/doc/source/example/reference/commands/select/query_expander_substitution_table.log \ + $(top_srcdir)/doc/source/example/reference/commands/select/query_expansion_complex.log \ + $(top_srcdir)/doc/source/example/reference/commands/select/query_expansion_substitute.log \ + $(top_srcdir)/doc/source/example/reference/commands/select/query_expansion_substitution_table.log \ $(top_srcdir)/doc/source/example/reference/commands/select/query_flags_allow_column.log \ $(top_srcdir)/doc/source/example/reference/commands/select/query_flags_allow_leading_not.log \ $(top_srcdir)/doc/source/example/reference/commands/select/query_flags_allow_update.log \ @@ -472,9 +472,9 @@ source_files_relative_from_doc_dir = \ source/example/reference/commands/select/paging.log \ source/example/reference/commands/select/query_and.log \ source/example/reference/commands/select/query_equal.log \ - source/example/reference/commands/select/query_expander_complex.log \ - source/example/reference/commands/select/query_expander_substitute.log \ - source/example/reference/commands/select/query_expander_substitution_table.log \ + source/example/reference/commands/select/query_expansion_complex.log \ + source/example/reference/commands/select/query_expansion_substitute.log \ + source/example/reference/commands/select/query_expansion_substitution_table.log \ source/example/reference/commands/select/query_flags_allow_column.log \ source/example/reference/commands/select/query_flags_allow_leading_not.log \ source/example/reference/commands/select/query_flags_allow_update.log \ Added: doc/source/example/reference/commands/select/query_expansion_complex.log (+52 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/select/query_expansion_complex.log 2013-03-19 19:05:18 +0900 (c60dd7b) @@ -0,0 +1,52 @@ +Execution example:: + + load --table Thesaurus + [ + {"_key": "popular", "synonym": ["popular", "n_likes:>=10"]} + ] + # [[0, 1337566253.89858, 0.000355720520019531], 1] + select Entries --match_columns content --query "popular" --query_expansion Thesaurus.synonym + # [ + # [ + # 0, + # 1337566253.89858, + # 0.000355720520019531 + # ], + # [ + # [ + # [ + # 2 + # ], + # [ + # [ + # "_id", + # "UInt32" + # ], + # [ + # "_key", + # "ShortText" + # ], + # [ + # "content", + # "Text" + # ], + # [ + # "n_likes", + # "UInt32" + # ] + # ], + # [ + # 2, + # "Groonga", + # "I started to use groonga. It's very fast!", + # 10 + # ], + # [ + # 3, + # "Mroonga", + # "I also started to use mroonga. It's also very fast! Really fast!", + # 15 + # ] + # ] + # ] + # ] Added: doc/source/example/reference/commands/select/query_expansion_substitute.log (+131 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/select/query_expansion_substitute.log 2013-03-19 19:05:18 +0900 (fa0e65b) @@ -0,0 +1,131 @@ +Execution example:: + + select Entries --match_columns content --query "mroonga" + # [ + # [ + # 0, + # 1337566253.89858, + # 0.000355720520019531 + # ], + # [ + # [ + # [ + # 1 + # ], + # [ + # [ + # "_id", + # "UInt32" + # ], + # [ + # "_key", + # "ShortText" + # ], + # [ + # "content", + # "Text" + # ], + # [ + # "n_likes", + # "UInt32" + # ] + # ], + # [ + # 3, + # "Mroonga", + # "I also started to use mroonga. It's also very fast! Really fast!", + # 15 + # ] + # ] + # ] + # ] + select Entries --match_columns content --query "mroonga" --query_expansion Thesaurus.synonym + # [ + # [ + # 0, + # 1337566253.89858, + # 0.000355720520019531 + # ], + # [ + # [ + # [ + # 2 + # ], + # [ + # [ + # "_id", + # "UInt32" + # ], + # [ + # "_key", + # "ShortText" + # ], + # [ + # "content", + # "Text" + # ], + # [ + # "n_likes", + # "UInt32" + # ] + # ], + # [ + # 3, + # "Mroonga", + # "I also started to use mroonga. It's also very fast! Really fast!", + # 15 + # ], + # [ + # 5, + # "Good-bye Tritonn", + # "I also migrated all Tritonn system!", + # 3 + # ] + # ] + # ] + # ] + select Entries --match_columns content --query "((mroonga) OR (tritonn) OR (groonga mysql))" + # [ + # [ + # 0, + # 1337566253.89858, + # 0.000355720520019531 + # ], + # [ + # [ + # [ + # 2 + # ], + # [ + # [ + # "_id", + # "UInt32" + # ], + # [ + # "_key", + # "ShortText" + # ], + # [ + # "content", + # "Text" + # ], + # [ + # "n_likes", + # "UInt32" + # ] + # ], + # [ + # 3, + # "Mroonga", + # "I also started to use mroonga. It's also very fast! Really fast!", + # 15 + # ], + # [ + # 5, + # "Good-bye Tritonn", + # "I also migrated all Tritonn system!", + # 3 + # ] + # ] + # ] + # ] Added: doc/source/example/reference/commands/select/query_expansion_substitution_table.log (+12 -0) 100644 =================================================================== --- /dev/null +++ doc/source/example/reference/commands/select/query_expansion_substitution_table.log 2013-03-19 19:05:18 +0900 (5c7d6cf) @@ -0,0 +1,12 @@ +Execution example:: + + table_create Thesaurus TABLE_PAT_KEY|KEY_NORMALIZE ShortText + # [[0, 1337566253.89858, 0.000355720520019531], true] + column_create Thesaurus synonym COLUMN_VECTOR ShortText + # [[0, 1337566253.89858, 0.000355720520019531], true] + load --table Thesaurus + [ + {"_key": "mroonga", "synonym": ["mroonga", "tritonn", "groonga mysql"]}, + {"_key": "groonga", "synonym": ["groonga", "senna"]} + ] + # [[0, 1337566253.89858, 0.000355720520019531], 2] Modified: doc/source/example/tutorial/query_expansion-3.log (+2 -2) =================================================================== --- doc/source/example/tutorial/query_expansion-3.log 2013-03-19 19:01:02 +0900 (96ecb8d) +++ doc/source/example/tutorial/query_expansion-3.log 2013-03-19 19:05:18 +0900 (def84e6) @@ -1,6 +1,6 @@ Execution example:: - select Doc --match_columns body --query "シークァーサー" --query_expander Synonym.body + select Doc --match_columns body --query "シークァーサー" --query_expansion Synonym.body # [ # [ # 0, @@ -39,7 +39,7 @@ Execution example:: # ] # ] # ] - select Doc --match_columns body --query "シークヮーサー" --query_expander Synonym.body + select Doc --match_columns body --query "シークヮーサー" --query_expansion Synonym.body # [ # [ # 0, Modified: doc/source/reference/commands/select.txt (+89 -98) =================================================================== --- doc/source/reference/commands/select.txt 2013-03-19 19:01:02 +0900 (da02cb3) +++ doc/source/reference/commands/select.txt 2013-03-19 19:05:18 +0900 (2043463) @@ -41,7 +41,6 @@ Syntax [match_escalation_threshold=0] [query_expansion=null] [query_flags=ALLOW_PRAGMA|ALLOW_COLUMN|ALLOW_UPDATE|ALLOW_LEADING_NOT|NONE] - [query_expander=null] Usage ----- @@ -452,7 +451,95 @@ more searches aren't executed. And no records are matched. ``query_expansion`` """"""""""""""""""" -Deprecated. Use :ref:`query-expander` instead. +It's for query expansion. Query expansion substitutes specific words +to another words in query. Nomally, it's used for synonym search. + +It specifies a column that is used to substitute ``query`` parameter +value. The format of this parameter value is +"``${TABLE}.${COLUMN}``". For example, "``Terms.synonym``" specifies +``synonym`` column in ``Terms`` table. + +Table for query expansion is called "substitution table". Substitution +table's key must be ``ShortText``. So array table (``TABLE_NO_KEY``) +can't be used for query expansion. Because array table doesn't have +key. + +Column for query expansion is called "substitution +column". Substitution column's value type must be +``ShortText``. Column type must be vector (``COLUMN_VECTOR``). + +Query expansion substitutes key of substitution table in query with +values in substitution column. If a word in ``query`` is a key of +substitution table, the word is substituted with substitution column +value that is associated with the key. Substition isn't performed +recursively. It means that substitution target words in substituted +query aren't substituted. + +Here is a sample substitution table to show a simple +``query_expansion`` usage example. + +.. groonga-command +.. include:: ../../example/reference/commands/select/query_expansion_substitution_table.log +.. table_create Thesaurus TABLE_PAT_KEY|KEY_NORMALIZE ShortText +.. column_create Thesaurus synonym COLUMN_VECTOR ShortText +.. load --table Thesaurus +.. [ +.. {"_key": "mroonga", "synonym": ["mroonga", "tritonn", "groonga mysql"]}, +.. {"_key": "groonga", "synonym": ["groonga", "senna"]} +.. ] + +``Thesaurus`` substitution table has two synonyms, ``"mroonga"`` and +``"groonga"``. If an user searches with ``"mroonga"``, groonga +searches with ``"((mroonga) OR (tritonn) OR (groonga mysql))"``. If an +user searches with ``"groonga"``, groonga searchs with ``"((groonga) +OR (senna))"``. Nomrally, it's good idea that substitution table has +``KEY_NORMALIZE`` flag. If the flag is used, substitute target word is +matched in case insensitive manner. + +Note that those synonym values include the key value such as +``"mroonga"`` and ``"groonga"``. It's recommended that you include the +key value. If you don't include key value, substituted value doesn't +include the original substitute target value. Normally, including the +original value is better search result. If you have a word that you +don't want to be searched, you should not include the original +word. For example, you can implement "stop words" by an empty vector +value. + +Here is a simple ``query_expansion`` usage example. + +.. groonga-command +.. include:: ../../example/reference/commands/select/query_expansion_substitute.log +.. select Entries --match_columns content --query "mroonga" +.. select Entries --match_columns content --query "mroonga" --query_expansion Thesaurus.synonym +.. select Entries --match_columns content --query "((mroonga) OR (tritonn) OR (groonga mysql))" + +The first ``select`` command doesn't use query expansion. So a record +that has ``"tritonn"`` isn't found. The second ``select`` command uses +query expansion. So a record that has ``"tritonn"`` is found. The +third ``select`` command doesn't use query expansion but it is same as +the second ``select`` command. The third one uses expanded query. + +Each substitute value can contain any :doc:`/reference/grn_expr/query_syntax` syntax +such as ``(...)`` and ``OR``. You can use complex substitution by +using those syntax. + +Here is a complex substitution usage example that uses query syntax. + +.. groonga-command +.. include:: ../../example/reference/commands/select/query_expansion_complex.log +.. load --table Thesaurus +.. [ +.. {"_key": "popular", "synonym": ["popular", "n_likes:>=10"]} +.. ] +.. select Entries --match_columns content --query "popular" --query_expansion Thesaurus.synonym + +The ``load`` command registers a new synonym ``"popular"``. It is +substituted with ``((popular) OR (n_likes:>=10))``. The substituted +query means that "popular" is containing the word "popular" or 10 or +more liked entries. + +The ``select`` command outputs records that ``n_likes`` column value +is equal to or more than ``10`` from ``Entries`` table. .. _query-flags: @@ -546,102 +633,6 @@ specified. See also :doc:`/reference/grn_expr/query_syntax`. -.. _query-expander: - -``query_expander`` -"""""""""""""""""" - -It's for query expansion. Query expansion substitutes specific words -to another words in query. Nomally, it's used for synonym search. - -It specifies a column that is used to substitute ``query`` parameter -value. The format of this parameter value is -"``${TABLE}.${COLUMN}``". For example, "``Terms.synonym``" specifies -``synonym`` column in ``Terms`` table. - -Table for query expansion is called "substitution table". Substitution -table's key must be ``ShortText``. So array table (``TABLE_NO_KEY``) -can't be used for query expansion. Because array table doesn't have -key. - -Column for query expansion is called "substitution -column". Substitution column's value type must be -``ShortText``. Column type must be vector (``COLUMN_VECTOR``). - -Query expansion substitutes key of substitution table in query with -values in substitution column. If a word in ``query`` is a key of -substitution table, the word is substituted with substitution column -value that is associated with the key. Substition isn't performed -recursively. It means that substitution target words in substituted -query aren't substituted. - -Here is a sample substitution table to show a simple -``query_expander`` usage example. - -.. groonga-command -.. include:: ../../example/reference/commands/select/query_expander_substitution_table.log -.. table_create Thesaurus TABLE_PAT_KEY|KEY_NORMALIZE ShortText -.. column_create Thesaurus synonym COLUMN_VECTOR ShortText -.. load --table Thesaurus -.. [ -.. {"_key": "mroonga", "synonym": ["mroonga", "tritonn", "groonga mysql"]}, -.. {"_key": "groonga", "synonym": ["groonga", "senna"]} -.. ] - -``Thesaurus`` substitution table has two synonyms, ``"mroonga"`` and -``"groonga"``. If an user searches with ``"mroonga"``, groonga -searches with ``"((mroonga) OR (tritonn) OR (groonga mysql))"``. If an -user searches with ``"groonga"``, groonga searchs with ``"((groonga) -OR (senna))"``. Nomrally, it's good idea that substitution table has -``KEY_NORMALIZE`` flag. If the flag is used, substitute target word is -matched in case insensitive manner. - -Note that those synonym values include the key value such as -``"mroonga"`` and ``"groonga"``. It's recommended that you include the -key value. If you don't include key value, substituted value doesn't -include the original substitute target value. Normally, including the -original value is better search result. If you have a word that you -don't want to be searched, you should not include the original -word. For example, you can implement "stop words" by an empty vector -value. - -Here is a simple ``query_expander`` usage example. - -.. groonga-command -.. include:: ../../example/reference/commands/select/query_expander_substitute.log -.. select Entries --match_columns content --query "mroonga" -.. select Entries --match_columns content --query "mroonga" --query_expander Thesaurus.synonym -.. select Entries --match_columns content --query "((mroonga) OR (tritonn) OR (groonga mysql))" - -The first ``select`` command doesn't use query expansion. So a record -that has ``"tritonn"`` isn't found. The second ``select`` command uses -query expansion. So a record that has ``"tritonn"`` is found. The -third ``select`` command doesn't use query expansion but it is same as -the second ``select`` command. The third one uses expanded query. - -Each substitute value can contain any :doc:`/reference/grn_expr/query_syntax` syntax -such as ``(...)`` and ``OR``. You can use complex substitution by -using those syntax. - -Here is a complex substitution usage example that uses query syntax. - -.. groonga-command -.. include:: ../../example/reference/commands/select/query_expander_complex.log -.. load --table Thesaurus -.. [ -.. {"_key": "popular", "synonym": ["popular", "n_likes:>=10"]} -.. ] -.. select Entries --match_columns content --query "popular" --query_expander Thesaurus.synonym - -The ``load`` command registers a new synonym ``"popular"``. It is -substituted with ``((popular) OR (n_likes:>=10))``. The substituted -query means that "popular" is containing the word "popular" or 10 or -more liked entries. - -The ``select`` command outputs records that ``n_likes`` column value -is equal to or more than ``10`` from ``Entries`` table. - - Output related parameters ^^^^^^^^^^^^^^^^^^^^^^^^^ Modified: doc/source/tutorial/query_expansion.txt (+5 -5) =================================================================== --- doc/source/tutorial/query_expansion.txt 2013-03-19 19:01:02 +0900 (4411dd6) +++ doc/source/tutorial/query_expansion.txt 2013-03-19 19:05:18 +0900 (42dfdf4) @@ -8,7 +8,7 @@ クエリ拡張 ========== -groongaでは、 :doc:`/reference/commands/select` コマンドにquery_expanderパラメータを指定することによって、ユーザが指定した検索文字列を適宜拡張することが可能です。 +groongaでは、 :doc:`/reference/commands/select` コマンドにquery_expansionパラメータを指定することによって、ユーザが指定した検索文字列を適宜拡張することが可能です。 たとえば、ユーザが'シークヮーサー'という文字列で検索した場合に、'シークヮーサー OR シークァーサー'で検索した場合と同一の結果を返すことによって、本来ユーザが必要とする結果をよりもれなく検索できるようになります。 @@ -45,18 +45,18 @@ TODO: 文字列型のベクターカラムでも可能であり、その場合 検索 ---- -それでは実際に、準備した置換テーブルを使ってみましょう。まずは、query_expanderパラメータを指定せずにselectコマンドを使って検索してみます。 +それでは実際に、準備した置換テーブルを使ってみましょう。まずは、query_expansionパラメータを指定せずにselectコマンドを使って検索してみます。 .. groonga-command .. include:: ../example/tutorial/query_expansion-2.log .. select Doc --match_columns body --query "シークァーサー" .. select Doc --match_columns body --query "シークヮーサー" -指定された文字列に完全に一致するレコードのみがそれぞれヒットします。次に、query_expanderパラメータに、準備したSynonymテーブルのbodyカラムを指定してみましょう。 +指定された文字列に完全に一致するレコードのみがそれぞれヒットします。次に、query_expansionパラメータに、準備したSynonymテーブルのbodyカラムを指定してみましょう。 .. groonga-command .. include:: ../example/tutorial/query_expansion-3.log -.. select Doc --match_columns body --query "シークァーサー" --query_expander Synonym.body -.. select Doc --match_columns body --query "シークヮーサー" --query_expander Synonym.body +.. select Doc --match_columns body --query "シークァーサー" --query_expansion Synonym.body +.. select Doc --match_columns body --query "シークヮーサー" --query_expansion Synonym.body どちらのクエリ文字列も、"(シークァーサー OR シークヮーサー)"という文字列に置換されてから検索されるため、表記の揺れを吸収して検索できるようになりました。 -------------- next part -------------- HTML����������������������������...ダウンロード