[Groonga-commit] groonga/groonga [master] [doc][suggest] add examples.

Back to archive index

null+****@clear***** null+****@clear*****
2011年 8月 17日 (水) 15:23:49 JST


Kouhei Sutou	2011-08-17 06:23:49 +0000 (Wed, 17 Aug 2011)

  New Revision: d8974382a319c35eb2402981fff660199068f1c6

  Log:
    [doc][suggest] add examples.

  Modified files:
    doc/source/commands/suggest.txt

  Modified: doc/source/commands/suggest.txt (+137 -17)
===================================================================
--- doc/source/commands/suggest.txt    2011-08-17 04:23:36 +0000 (bb8aa72)
+++ doc/source/commands/suggest.txt    2011-08-17 06:23:49 +0000 (aa216cb)
@@ -2,6 +2,10 @@
 
 .. highlightlang:: none
 
+.. groonga-command
+.. % groonga-suggest-create-dataset /tmp/groonga-databases/suggest query
+.. database: suggest
+
 suggest
 =======
 
@@ -65,10 +69,10 @@ OPTIONS
 
 ``table``
   It specifies table name that has ``item_${DATA_SET_NAME}` format.
-  For example, ``item_shops`` is a table name if you created
+  For example, ``item_query`` is a table name if you created
   dataset by the following command::
 
-    groonga-suggest-create-dataset /tmp/db-path shops
+    groonga-suggest-create-dataset /tmp/db-path query
 
 ``column``
   It specifies a column name that has furigana in
@@ -79,41 +83,157 @@ OPTIONS
   suggestion.
 
 ``sortby``
-  TODO
+  It specifies sort key.
+
+  Default:
+    ``-_score``
 
 ``output_columns``
-  TODO
+  It specifies output column values.
+
+  Default:
+    ``_key,_score``
 
 ``offset``
-  TODO
+  It specifies returned records offset.
+
+  Default:
+    ``0``
 
 ``limit``
-  TODO
+  It specifies number of returned records
+
+  Default:
+    ``10``
 
 ``threshold``
-  TODO
+  It specifies threshold. Returned records must have
+  ``_score`` that is greater than or equal to ``threshold``.
+
+  Default:
+    ``100``
 
 ``prefix_search``
-  TODO
+  It specifies whether optional prefix search is used or not
+  in completion.
+
+  Here are available values:
+
+    ``yes``
+      Prefix search is always used.
+
+    ``no``
+      Prefix search is never used.
+
+    ``auto``
+      Prefix search is used only when other search can't
+      find any records.
+
+  Default:
+    ``auto``
 
 RETURN VALUE
 ------------
 
-JSON Format
+JSON format
 ^^^^^^^^^^^
 
-::
+Here is a returned JSON format::
+
+ {"type1": [["candidate1", score of candidate1],
+            ["candidate2", score of candidate2],
+            ...],
+  "type2": [["candidate1", score of candidate1],
+            ["candidate2", score of candidate2],
+            ...],
+  ...}
+
+``type``
+
+  A type specified by ``types``.
+
+``candidate``
 
- {"タイプ1":[["候補1", 候補1のスコア], ["候補2", 候補2のスコア], ...], ...}
+  A candidate for completion, correction or suggestion.
 
- ``タイプ``
+``score of candidate``
 
-   types引数に指定した値。
+  A score of corresponding ``candidate``. It means that
+  higher score candidate is more likely candidate for
+  completion, correction or suggestion. Returned candidates
+  are sorted by ``score of candidate`` descending by
+  default.
 
- ``候補``
+EXAMPLE
+-------
+
+Here are learned data for completion.
+
+.. groonga-command
+.. include:: ../commands/suggest-learn-completion.log
+.. load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)'
+.. [
+.. {"sequence": "1", "time": 1312950803.86057, "item": "e"},
+.. {"sequence": "1", "time": 1312950803.96857, "item": "en"},
+.. {"sequence": "1", "time": 1312950804.26057, "item": "eng"},
+.. {"sequence": "1", "time": 1312950804.56057, "item": "engi"},
+.. {"sequence": "1", "time": 1312950804.76057, "item": "engin"},
+.. {"sequence": "1", "time": 1312950805.86057, "item": "engine", "type": "submit"}
+.. ]
+
+Here are learned data for correction.
+
+.. groonga-command
+.. include:: ../commands/suggest-learn-correction.log
+.. load --table event_item --each 'suggest_preparer(_id, type, item, sequence, time, pair_item)'
+.. [
+.. {"sequence": "2", "time": 1312950803.86057, "item": "s"},
+.. {"sequence": "2", "time": 1312950803.96857, "item": "sa"},
+.. {"sequence": "2", "time": 1312950804.26057, "item": "sae"},
+.. {"sequence": "2", "time": 1312950804.56057, "item": "saer"},
+.. {"sequence": "2", "time": 1312950804.76057, "item": "saerc"},
+.. {"sequence": "2", "time": 1312950805.76057, "item": "saerch", "type": "submit"},
+.. {"sequence": "2", "time": 1312950809.76057, "item": "serch"},
+.. {"sequence": "2", "time": 1312950810.86057, "item": "search", "type": "submit"}
+.. ]
+
+Here are learned data for suggestion.
+
+.. groonga-command
+.. include:: ../commands/suggest-learn-suggestion.log
+.. load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)'
+.. [
+.. {"sequence": "3", "time": 1312950803.86057, "item": "search engine", "type": "submit"},
+.. {"sequence": "3", "time": 1312950808.86057, "item": "web search realtime", "type": "submit"}
+.. ]
+
+Here is a completion example.
 
-   補完・修正・提案の候補。
+.. groonga-command
+.. include:: ../commands/suggest-completion.log
+.. suggest --table item_query --column kana --types complete --threshold 1 --query en
 
- ``候補のスコア``
+Here is a correction example.
+
+.. groonga-command
+.. include:: ../commands/suggest-correction.log
+.. suggest --table item_query --column kana --types correct --threshold 1 --query saerch
+
+Here is a suggestion example.
+
+.. groonga-command
+.. include:: ../commands/suggest-suggestion.log
+.. suggest --table item_query --column kana --types suggest --threshold 1 --query search
+
+Here is a mixed example.
+
+.. groonga-command
+.. include:: ../commands/suggest-mixed.log
+.. suggest --table item_query --column kana --types complete|correct|suggest --threshold 1 --query search
+
+
+SEE ALSO
+--------
 
-   補完・修正・提案として優れたものほど高くなる数値。結果は、スコア順にソートされている。
+  * :doc:`/suggest`
+  * :doc:`/executables/groonga-suggest-create-dataset`




Groonga-commit メーリングリストの案内
Back to archive index