Debian Codegraph @

doc/source/reference/commands/suggest.rst

raw
1 .. -*- rst -*-
2
3 .. groonga-command
4 .. database: suggest
5 .. $ groonga-suggest-create-dataset ${DB_PATH} query
6
7 ``suggest``
8 ===========
9
10 .. note::
11
12 The suggest feature specification isn't stable. The
13 specification may be changed.
14
15 Summary
16 -------
17
18 suggest - returns completion, correction and/or suggestion for a query.
19
20 The suggest command returns completion, correction and/or
21 suggestion for a specified query.
22
23 See :doc:`/reference/suggest/introduction` about completion,
24 correction and suggestion.
25
26 Syntax
27 ------
28 ::
29
30 suggest types
31 table
32 column
33 query
34 [sortby=-_score]
35 [output_columns=_key,_score]
36 [offset=0]
37 [limit=10]
38 [frequency_threshold=100]
39 [conditional_probability_threshold=0.2]
40 [prefix_search=auto]
41
42 Usage
43 -----
44
45 Here are learned data for completion.
46
47 .. groonga-command
48 .. include:: ../../example/reference/commands/suggest-learn-completion.log
49 .. load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)'
50 .. [
51 .. {"sequence": "1", "time": 1312950803.86057, "item": "e"},
52 .. {"sequence": "1", "time": 1312950803.96857, "item": "en"},
53 .. {"sequence": "1", "time": 1312950804.26057, "item": "eng"},
54 .. {"sequence": "1", "time": 1312950804.56057, "item": "engi"},
55 .. {"sequence": "1", "time": 1312950804.76057, "item": "engin"},
56 .. {"sequence": "1", "time": 1312950805.86057, "item": "engine", "type": "submit"}
57 .. ]
58
59 Here are learned data for correction.
60
61 .. groonga-command
62 .. include:: ../../example/reference/commands/suggest-learn-correction.log
63 .. load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)'
64 .. [
65 .. {"sequence": "2", "time": 1312950803.86057, "item": "s"},
66 .. {"sequence": "2", "time": 1312950803.96857, "item": "sa"},
67 .. {"sequence": "2", "time": 1312950804.26057, "item": "sae"},
68 .. {"sequence": "2", "time": 1312950804.56057, "item": "saer"},
69 .. {"sequence": "2", "time": 1312950804.76057, "item": "saerc"},
70 .. {"sequence": "2", "time": 1312950805.76057, "item": "saerch", "type": "submit"},
71 .. {"sequence": "2", "time": 1312950809.76057, "item": "serch"},
72 .. {"sequence": "2", "time": 1312950810.86057, "item": "search", "type": "submit"}
73 .. ]
74
75 Here are learned data for suggestion.
76
77 .. groonga-command
78 .. include:: ../../example/reference/commands/suggest-learn-suggestion.log
79 .. load --table event_query --each 'suggest_preparer(_id, type, item, sequence, time, pair_query)'
80 .. [
81 .. {"sequence": "3", "time": 1312950803.86057, "item": "search engine", "type": "submit"},
82 .. {"sequence": "3", "time": 1312950808.86057, "item": "web search realtime", "type": "submit"}
83 .. ]
84
85 Here is a completion example.
86
87 .. groonga-command
88 .. include:: ../../example/reference/commands/suggest-completion.log
89 .. suggest --table item_query --column kana --types complete --frequency_threshold 1 --query en
90
91 Here is a correction example.
92
93 .. groonga-command
94 .. include:: ../../example/reference/commands/suggest-correction.log
95 .. suggest --table item_query --column kana --types correct --frequency_threshold 1 --query saerch
96
97 Here is a suggestion example.
98
99 .. groonga-command
100 .. include:: ../../example/reference/commands/suggest-suggestion.log
101 .. suggest --table item_query --column kana --types suggest --frequency_threshold 1 --query search
102
103 Here is a mixed example.
104
105 .. groonga-command
106 .. include:: ../../example/reference/commands/suggest-mixed.log
107 .. suggest --table item_query --column kana --types complete|correct|suggest --frequency_threshold 1 --query search
108
109 Parameters
110 ----------
111
112 ``types``
113 Specifies what types are returned by the suggest
114 command.
115
116 Here are available types:
117
118 ``complete``
119 The suggest command does completion.
120
121 ``correct``
122 The suggest command does correction.
123
124 ``suggest``
125 The suggest command does suggestion.
126
127 You can specify one or more types separated by ``|``.
128 Here are examples:
129
130 It returns correction::
131
132 correct
133
134 It returns correction and suggestion::
135
136 correct|suggest
137
138 It returns complete, correction and suggestion::
139
140 complete|correct|suggest
141
142 ``table``
143 Specifies table name that has ``item_${DATA_SET_NAME}`` format.
144 For example, ``item_query`` is a table name if you created
145 dataset by the following command::
146
147 groonga-suggest-create-dataset /tmp/db-path query
148
149 ``column``
150 Specifies a column name that has furigana in
151 Katakana in ``table`` table.
152
153 ``query``
154 Specifies query for completion, correction and/or
155 suggestion.
156
157 ``sortby``
158 Specifies sort key.
159
160 Default:
161 ``-_score``
162
163 ``output_columns``
164 Specifies output columns.
165
166 Default:
167 ``_key,_score``
168
169 ``offset``
170 Specifies returned records offset.
171
172 Default:
173 ``0``
174
175 ``limit``
176 Specifies number of returned records.
177
178 Default:
179 ``10``
180
181 ``frequency_threshold``
182 Specifies threshold for item frequency. Returned records must have
183 ``_score`` that is greater than or equal to ``frequency_threshold``.
184
185 Default:
186 ``100``
187
188 ``conditional_probability_threshold``
189
190 Specifies threshold for conditional
191 probability. Conditional probability is used for learned
192 data. It is probability of query submission when ``query``
193 is occurred. Returned records must have conditional
194 probability that is greater than or equal to
195 ``conditional_probability_threshold``.
196
197 Default:
198 ``0.2``
199
200 ``prefix_search``
201 Specifies whether optional prefix search is used or not
202 in completion.
203
204 Here are available values:
205
206 ``yes``
207 Prefix search is always used.
208
209 ``no``
210 Prefix search is never used.
211
212 ``auto``
213 Prefix search is used only when other search can't
214 find any records.
215
216 Default:
217 ``auto``
218
219 ``similar_search``
220 Specifies whether optional similar search is used or not
221 in correction.
222
223 Here are available values:
224
225 ``yes``
226 Similar search is always used.
227
228 ``no``
229 Similar search is never used.
230
231 ``auto``
232 Similar search is used only when other search can't
233 find any records.
234
235 Default:
236 ``auto``
237
238 Return value
239 ------------
240
241 Here is a returned JSON format::
242
243 {"type1": [["candidate1", score of candidate1],
244 ["candidate2", score of candidate2],
245 ...],
246 "type2": [["candidate1", score of candidate1],
247 ["candidate2", score of candidate2],
248 ...],
249 ...}
250
251 ``type``
252
253 A type specified by ``types``.
254
255 ``candidate``
256
257 A candidate for completion, correction or suggestion.
258
259 ``score of candidate``
260
261 A score of corresponding ``candidate``. It means that
262 higher score candidate is more likely candidate for
263 completion, correction or suggestion. Returned candidates
264 are sorted by ``score of candidate`` descending by
265 default.
266
267 See also
268 --------
269
270 * :doc:`/reference/suggest`
271 * :doc:`/reference/executables/groonga-suggest-create-dataset`