Debian Codegraph @

doc/source/reference/functions/highlight_full.rst

raw
1 .. -*- rst -*-
2
3 .. groonga-command
4 .. database: functions_highlight_full
5
6 ``highlight_full``
7 ==================
8
9 .. versionadded:: 4.0.5
10
11 Summary
12 -------
13
14 ``highlight_full`` tags target text. It can use to highlight the search
15 keyword. It can specify use/not use HTML escape, the normalizer name and
16 change the tag for each keyword.
17
18 Syntax
19 ------
20
21 ``highlight_full`` has required parameter and optional parameter::
22
23 highlight_full(column, normalizer_name, use_html_escape,
24 keyword1, open_tag1, close_tag1,
25 ...
26 [keywordN, open_tagN, close_tagN])
27
28 Usage
29 -----
30
31 Here are a schema definition and sample data to show usage.
32
33 .. groonga-command
34 .. include:: ../../example/reference/functions/highlight_full/usage_setup.log
35 .. table_create Entries TABLE_NO_KEY
36 .. column_create Entries body COLUMN_SCALAR ShortText
37 .. table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram --normalizer NormalizerAuto
38 .. column_create Terms document_index COLUMN_INDEX|WITH_POSITION Entries body
39 .. load --table Entries
40 .. [
41 .. {"body": "Mroonga is a MySQL storage engine based on Groonga. <b>Rroonga</b> is a Ruby binding of Groonga."}
42 .. ]
43
44 ``highlight_full`` can be used in only ``--output_columns`` in
45 :doc:`/reference/commands/select` before version 10.0.6 (exclusive).
46 However, it can be also used in ``--output_columns`` in
47 :doc:`/reference/commands/logical_select` since version 10.0.6.
48
49 ``highlight_full`` requires :doc:`/reference/command/command_version` 2
50 or later.
51
52 The following example uses HTML escape and normalizer is ``NormalizeAuto``.
53 It specifies the tags ``<span class="keyword1">`` and ``</span>`` of the
54 keyword ``groonga``, and the tags ``<span class="keyword2">`` and ``</span>``
55 of the keyword ``mysql``.
56
57 .. groonga-command
58 .. include:: ../../example/reference/functions/highlight_full/usage_basic.log
59 .. select Entries --output_columns 'highlight_full(body, "NormalizerAuto", true, "Groonga", "<span class=\\"keyword1\\">", "</span>", "mysql", "<span class=\\"keyword2\\">", "</span>")' --command_version 2
60
61 The text are scanned by the keywords for tagging after they are normalized
62 by ``NormalizerAuto`` normalizer.
63
64 ``--query "groonga mysql"`` matches to the first record's body.
65 ``highlight_full`` surrounds the keywords ``groonga`` contained in the text
66 with ``<span class="keyword1">`` and ``</span>``, and the keywords ``mysql``
67 contained in the text with with ``<span class="keyword2">`` and ``</span>``.
68
69 Special characters such as ``<`` and ``>`` are escapsed as ``&lt;`` and
70 ``&gt;``.
71
72 You can specify string literal instead of column.
73
74 .. groonga-command
75 .. include:: ../../example/reference/functions/highlight_full/usage_string_literal.log
76 .. select Entries --output_columns 'highlight_full("Groonga is very fast fulltext search engine.", "NormalizerAuto", true, "Groonga", "<span class=\\"keyword1\\">", "</span>", "mysql", "<span class=\\"keyword2\\">", "</span>")' --command_version 2 --match_columns body --query "groonga"
77
78 Parameters
79 ----------
80 There are three required parameters, ``column``, ``normalizer_name`` and ``use_html_escape``.
81 There are three or over optional parameters, ``keywordN``, ``open_tagN`` and ``end_tagN``.
82
83 ``column``
84 ^^^^^^^^^^
85
86 Specifies a column of the table.
87
88 ``normalizer_name``
89 ^^^^^^^^^^^^^^^^^^^
90
91 Specifies a normalizer name.
92
93 ``use_html_escape``
94 ^^^^^^^^^^^^^^^^^^^
95
96 Specifies use or not use HTML escape. If it is ``true`` , use HTML escape.
97 If it is ``false`` , not use HTML escape.
98
99 ``keywordN``
100 ^^^^^^^^^^^^
101
102 Specifies a keyword for tagging.
103 You can specify multiple keywords for each three arguments.
104
105 ``open_tagN``
106 ^^^^^^^^^^^^^
107
108 Specifies a open tag.
109 You can specify multiple open tags for each three arguments.
110
111 ``close_tagN``
112 ^^^^^^^^^^^^^^
113
114 Specifies a close tag.
115 You can specify multiple close tags for each three arguments.
116
117 Return value
118 ------------
119
120 ``highlight_full`` returns a tagged string or ``null``. If
121 ``highlight_full`` can't find any keywords, it returns ``null``.
122
123 See also
124 --------
125
126 * :doc:`/reference/commands/select`
127 * :doc:`/reference/commands/logical_select`
128 * :doc:`/reference/functions/highlight_html`