Debian Codegraph @

doc/source/reference/tokenizers/token_table.rst

raw
1 .. -*- rst -*-
2
3 .. groonga-command
4 .. database: tokenizers_table
5
6 ``TokenTable``
7 ==============
8
9 Summary
10 -------
11
12 ``TokenTable`` is a tokenizer which treats only known keywords as a token.
13 The known keywords must be registered as a key in the table for ``TokenTable``.
14
15 For example, query contains a known keyword and a unknown keyword, only a known keyword is
16 used in search query (unknown keyword will be ignored). In other words, you can search contents with only known keywords.
17 Because of this characteristic, you need to maintain keyword table for a new keyword continuously.
18
19 Syntax
20 ------
21
22 ``TokenTable`` has a required parameter.
23
24 Specify the table::
25
26 TokenTable("table", TABLE)
27
28 ``TABLE`` must be created with ``--default_tokenizer 'TokenTable("table", TABLE)``.
29
30 Usage
31 -----
32
33 Here is an example of ``TokenTable``.
34 For example, let's search ``Raspberry Pie`` from ``Pies`` table.
35 The table which is used for keyword is ``Keywords``.
36
37 Here is the sample schema and data:
38
39 .. groonga-command
40 .. include:: ../../example/reference/tokenizers/token-table-schema.log
41 .. table_create Pies TABLE_NO_KEY
42 .. column_create Pies name COLUMN_SCALAR Text
43 .. table_create Keywords TABLE_PAT_KEY ShortText --default_tokenizer 'TokenTable("table", "Keywords")'
44 .. column_create Keywords index COLUMN_INDEX Pies name
45 .. load --table Keywords
46 .. [
47 .. {"_key": "Apple"},
48 .. {"_key": "Orange"},
49 .. {"_key": "Raspberry"}
50 .. ]
51 .. load --table Pies
52 .. [
53 .. {"name": "Apple Pie"},
54 .. {"name": "Orange Pie"},
55 .. {"name": "Raspberry Pie"},
56 .. {"name": "Stargazy Pie"}
57 .. ]
58
59 Then search ``Raspberry Pie`` with ``--query Raspberry``.
60
61 .. groonga-command
62 .. include:: ../../example/reference/tokenizers/token-table-search-raspberry.log
63 .. select Pies --match_columns name --query 'Raspberry'
64
65 As you expected, the above query matches the ``Raspberry Pie`` record.
66
67 Next, search ``Stargazy Pie`` with ``--query Stargazy``.
68
69 .. groonga-command
70 .. include:: ../../example/reference/tokenizers/token-table-search-stargazy.log
71 .. select Pies --match_columns name --query 'Stargazy'
72
73 In above example, as the keyword ``Stargazy`` is not registered in ``Keywords`` table yet, it doesn't match anything.
74
75 See also
76 ----------
77
78 * :doc:`../commands/tokenize`