5.5.3. mroonga_highlight_html()¶
バージョン 7.05 で追加.
5.5.3.1. 概要¶
mroonga_highlight_html() highlights the specified keywords in
target text. It surrounds each keyword with <span
class="keyword">...</span> and special characters in HTML such as
< and > are escaped. You can use the result as is safely in
HTML.
5.5.3.2. 構文¶
mroonga_highlight_html() には必須引数と省略可能引数とがあります。:
mroonga_highlight_html(text, query AS query)
mroonga_highlight_html(text, keyword1, ..., keywordN)
AS query is very important. You must specify it to extract keywords from query.
5.5.3.3. 使いかた¶
Here is a sample to highlight keywords "mroonga" and "groonga" in
target text by query "mroonga OR groonga". You must specify AS
query:
SELECT mroonga_highlight_html('Mroonga is the Groonga based storage engine.',
'mroonga OR groonga' AS query) AS highlighted;
Here is the result of the execution example:
+--------------------------------------------------------------------------------------------------------+
| highlighted |
+--------------------------------------------------------------------------------------------------------+
| <span class="keyword">Mroonga</span> is the <span class="keyword">Groonga</span> based storage engine. |
+--------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Here is a sample to highlight keywords "mroonga" and "groonga" in target text by keywords "mroonga" and "groonga":
SELECT mroonga_highlight_html('Mroonga is the Groonga based storage engine.',
'mroonga', 'groonga') AS highlighted;
Here is the result of the execution example:
+--------------------------------------------------------------------------------------------------------+
| highlighted |
+--------------------------------------------------------------------------------------------------------+
| <span class="keyword">Mroonga</span> is the <span class="keyword">Groonga</span> based storage engine. |
+--------------------------------------------------------------------------------------------------------+
5.5.3.4. 引数¶
5.5.3.4.1. 必須引数¶
必須引数が1つあります。
5.5.3.4.1.1. text¶
The column name of string or string value to be highlighted.
5.5.3.4.2. 省略可能引数¶
There are some optional parameters.
5.5.3.4.2.1. query¶
Specify query in Groonga's query syntax.
You must specify AS query to extract keywords from query like the
following:
SELECT mroonga_highlight_html('...', 'mroonga OR groonga' AS query);
5.5.3.4.2.2. keyword¶
Specify 0 or more keywords to be highlighted.
5.5.3.5. 返り値¶
It returns highlighted HTML. If optional parameter is not given, it
only escapes special characters in HTML such as <, > in
text.