Navigation Menu

Skip to content

Commit

Permalink
doc en: add execution example for mroonga_snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
kenhys committed Sep 27, 2012
1 parent 814913d commit aae282a
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions doc/source/userguide/storage.rst
Expand Up @@ -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
-------
Expand Down

0 comments on commit aae282a

Please sign in to comment.