[Groonga-commit] groonga/groonga [master] [doc][suggest] complete description about completion.

Back to archive index

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


Kouhei Sutou	2011-08-10 06:24:23 +0000 (Wed, 10 Aug 2011)

  New Revision: a9ba26df448fe28768cf6fb96ecddf6156b63f40

  Log:
    [doc][suggest] complete description about completion.

  Added files:
    doc/source/example/completion-1.log
  Modified files:
    doc/source/suggest/completion.txt
    doc/source/suggest/introduction.txt
    doc/source/update_execution_example.py

  Added: doc/source/example/completion-1.log (+5 -0) 100644
===================================================================
--- /dev/null
+++ doc/source/example/completion-1.log    2011-08-10 06:24:23 +0000 (2452290)
@@ -0,0 +1,5 @@
+Execution example::
+
+  > suggest --table item_query --column kana --types complete --threshold 1 --query en
+ [[0,1312956152.1091,0.001121197],{"complete":[[5],[["_key","ShortText"],["_score","Int32"]],["en",1],["engine",1],["engi",1],["engin",1],["eng",1]]}]
+ 
\ No newline at end of file

  Modified: doc/source/suggest/completion.txt (+77 -2)
===================================================================
--- doc/source/suggest/completion.txt    2011-08-10 03:23:44 +0000 (db58c2e)
+++ doc/source/suggest/completion.txt    2011-08-10 06:24:23 +0000 (077ed8e)
@@ -2,6 +2,9 @@
 
 .. highlightlang:: none
 
+.. groonga-command
+.. % groonga-suggest-create-dataset /tmp/example.db query
+
 Completion
 ==========
 
@@ -9,6 +12,7 @@ This section describes about the following of the completion
 feature:
 
   * How it works
+  * How to use
   * How to learn
 
 How it works
@@ -19,7 +23,7 @@ words:
 
   1. Prefix RK search against registered words.
   2. Cooccurrence search against learned data.
-  3. Optional prefix search against registered words.
+  3. Prefix search against registered words. (optional)
 
 Prefix RK search
 ^^^^^^^^^^^^^^^^
@@ -116,4 +120,75 @@ an user submission". Groonga doesn't treat user inputs
 before a minute ago.
 
 If an user inputs "sea" and cooccurrence search returns
-"search" because "sea".
+"search" because "sea" is in input column and completed word
+column is "search".
+
+Prefix search
+^^^^^^^^^^^^^
+
+Prefix search can find registered word that start with
+user's input. This search doesn't care about romaji,
+katakana and hiragana not like Prefix RK search.
+
+This search isn't always ran. It's just ran when it's
+requested explicitly or prefix both RK search and
+Cooccurrence search return nothing.
+
+For example, there is a registered word "search". An user
+can find "search" by "s", "se", "sea", "sear", "searc" and
+"search".
+
+How to use
+----------
+
+.. groonga-command
+.. 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"}
+.. ]
+
+Groonga provides :doc:`commands/suggest` command to use
+completion. `--type complete` option requests completion.
+
+For example, here is an command to get completion results by
+"en":
+
+.. groonga-command
+.. include:: ../example/completion-1.log
+.. suggest --table item_query --column kana --types complete --threshold 1 --query en
+
+How it learns
+-------------
+
+Cooccurrence search uses learned data. They are based on
+query logs, access logs and so on. To create learned data,
+groonga needs user input sequence with time stamp and user
+submit input with time stamp.
+
+For example, an user wants to search by "engine". The user
+inputs the query with the following sequence:
+
+  1. 2011-08-10T13:33:23+09:00: e
+  2. 2011-08-10T13:33:23+09:00: en
+  3. 2011-08-10T13:33:24+09:00: eng
+  4. 2011-08-10T13:33:24+09:00: engi
+  5. 2011-08-10T13:33:24+09:00: engin
+  6. 2011-08-10T13:33:25+09:00: engine (submit!)
+
+Groonga can be learned from the input sequence by the
+following command::
+
+  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"}
+  ]

  Modified: doc/source/suggest/introduction.txt (+2 -2)
===================================================================
--- doc/source/suggest/introduction.txt    2011-08-10 03:23:44 +0000 (ad4e1c7)
+++ doc/source/suggest/introduction.txt    2011-08-10 06:24:23 +0000 (5d1740f)
@@ -79,8 +79,8 @@ For example, there are registered related query pairs:
 +----------------------------+--------------------------+
 
 An user inputs "groonga" and groonga returns "groonga search
-engine" because "groonga" is in keyword and related query
-is "groonga search engine".
+engine" because "groonga" is in keyword column and related
+query column is "groonga search engine".
 
 An user inputs "MySQL" and groonga returns nothing because
 "MySQL" isn't in keyword

  Modified: doc/source/update_execution_example.py (+9 -3)
===================================================================
--- doc/source/update_execution_example.py    2011-08-10 03:23:44 +0000 (6b4055a)
+++ doc/source/update_execution_example.py    2011-08-10 06:24:23 +0000 (d395c53)
@@ -25,7 +25,7 @@ def execmd(cmd, fout):
   ioin.write(cmd + "\n")
   ioin.flush()
   if fout:
-    fout.write(a + "  ")
+    fout.write(a + " ")
   while True:
     out = select([ioout], [], [], 0.2)
     if len(out[0]):
@@ -34,7 +34,7 @@ def execmd(cmd, fout):
         stdout.write(a)
         if fout:
           if a == '\n':
-            fout.write(a + "  ")
+            fout.write(a + " ")
           else:
             fout.write(a)
     else:
@@ -71,7 +71,13 @@ def readfile(fname, outflag):
               os.makedirs(dir_name)
             fout = open(a, 'w')
             print '### write start : ' + a
-            fout.write("実行例 ::\n\n  ")
+            fout.write("Execution example::\n\n  ")
+        elif cmd.startswith('.. % '):
+          a = cmd[5:]
+          if fout:
+            fout.write(a + "\n  ")
+          print a
+          os.system(a)
         elif cmd.startswith('.. .. '):
           a = cmd[6:]
           if fout:




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