[Groonga-mysql-commit] mroonga/mroonga [fix-for-visual-studio] doc en: add execution example for mroonga_snippet

Back to archive index

HAYASHI Kentaro null+****@clear*****
Thu Sep 27 16:26:21 JST 2012


HAYASHI Kentaro	2012-09-27 16:26:21 +0900 (Thu, 27 Sep 2012)

  New Revision: aae282a138cb4fe618fdabc1243ea5bdd8e1a821
  https://github.com/mroonga/mroonga/commit/aae282a138cb4fe618fdabc1243ea5bdd8e1a821

  Log:
    doc en: add execution example for mroonga_snippet

  Modified files:
    doc/source/userguide/storage.rst

  Modified: doc/source/userguide/storage.rst (+43 -2)
===================================================================
--- doc/source/userguide/storage.rst    2012-09-27 14:54:30 +0900 (20fbf1b)
+++ doc/source/userguide/storage.rst    2012-09-27 16:26:21 +0900 (73e8b07)
@@ -348,11 +348,52 @@ mroonga_snippet function is included in mroonga as a User-Defined Function (UDF)
 
   mysql> CREATE FUNCTION mroonga_snippet RETURNS STRING SONAME 'ha_mroonga.so';
 
-Here is the results of execution examples::
+``mroonga_snippet`` function is useful for searching the text which contains keyword and associated one
+by using MATCH .. AGAINST syntax.
+
+Imagine searching the document which contains 'fulltext' as a keyword.
+Assume that some keyword such as 'MySQL' and 'search' are associated with 'fulltext'.
+
+``mroonga_snippet`` function meets above.
+
+Here is the schema definition for execution examples::
+
+  CREATE TABLE `snippet_test` (
+    `id` int(11) NOT NULL,
+    `text` text,
+    PRIMARY KEY (`id`),
+    FULLTEXT KEY `text` (`text`)
+  ) ENGINE=mroonga DEFAULT CHARSET=utf8
 
-TODO:
+Here is the sample data for execution examples::
 
+  insert into snippet_test (id, text) values (1, 'An open-source fulltext search engine and column store.');
+  insert into snippet_test (id, text) values (2, 'An open-source storage engine for fast fulltext search with MySQL.');
+  insert into snippet_test (id, text) values (3, 'Tritonn is a patched version of MySQL that supports better fulltext search function with Senna.');
 
+Here is the results of execution examples::
+
+  mysql> select * from snippet_test;
+  +----+-------------------------------------------------------------------------------------------------+
+  | id | text                                                                                            |
+  +----+-------------------------------------------------------------------------------------------------+
+  |  1 | An open-source fulltext search engine and column store.                                         |
+  |  2 | An open-source storage engine for fast fulltext search with MySQL.                              |
+  |  3 | Tritonn is a patched version of MySQL that supports better fulltext search function with Senna. |
+  +----+-------------------------------------------------------------------------------------------------+
+  3 rows in set (0.00 sec)
+  
+  mysql> select id, text, mroonga_snippet(text, 8, 2, 'ascii_general_ci', 1, 1, '...', '...<br>', 'fulltext', '<span class="w1">', '</span>', 'MySQL', '<span class="w2">', '</span>', 'search', '<span calss="w3">', '</span>') from snippet_test where match(text) against ('fulltext');
+  +----+-------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+  | id | text                                                                                            | mroonga_snippet(text, 8, 2, 'ascii_general_ci', 1, 1, '...', '...<br>', 'fulltext', '<span class="w1">', '</span>', 'MySQL', '<span class="w2">', '</span>', 'search', '<span calss="w3">', '</span>') |
+  +----+-------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+  |  1 | An open-source fulltext search engine and column store.                                         | ...<span class="w1">fulltext</span>...<br>... <span calss="w3">search</span> ...<br>                                                                                                                   |
+  |  2 | An open-source storage engine for fast fulltext search with MySQL.                              | ...<span class="w1">fulltext</span>...<br>... <span calss="w3">search</span> ...<br>                                                                                                                   |
+  |  3 | Tritonn is a patched version of MySQL that supports better fulltext search function with Senna. | ...f <span class="w2">MySQL</span> ...<br>...<span class="w1">fulltext</span>...<br>                                                                                                                   |
+  +----+-------------------------------------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
+  3 rows in set (0.00 sec)
+  
+The keyword 'fulltext' and associated keyword 'MySQL' and 'search' has been extracted.
 
 Logging
 -------
-------------- next part --------------
HTML����������������������������...
다운로드 



More information about the Groonga-mysql-commit mailing list
Back to archive index