File: query.html

package info (click to toggle)
groonga 11.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 121,576 kB
  • sloc: ansic: 801,209; javascript: 62,121; ruby: 46,206; cpp: 33,790; xml: 24,951; yacc: 13,333; sh: 7,776; python: 3,266; makefile: 2,315; perl: 133
file content (523 lines) | stat: -rw-r--r-- 30,324 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523


<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>7.15.17. query &#8212; Groonga v10.1.1-31-g1e46ba6 documentation</title>
    <link rel="stylesheet" href="../../_static/groonga.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
    <script src="../../_static/jquery.js"></script>
    <script src="../../_static/underscore.js"></script>
    <script src="../../_static/doctools.js"></script>
    <script src="../../_static/language_data.js"></script>
    
    <link rel="shortcut icon" href="../../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="7.15.18. rand" href="rand.html" />
    <link rel="prev" title="7.15.16. prefix_rk_search" href="prefix_rk_search.html" /> 
  </head><body>
<div class="header">
  <h1 class="title">
    <a id="top-link" href="../../index.html">
      <span class="project">groonga</span>
      <span class="separator">-</span>
      <span class="description">An open-source fulltext search engine and column store.</span>
    </a>
  </h1>

  <div class="other-language-links">
    <ul>
      <li><a href="../../../../ja/html/reference/functions/query.html">日本語</a></li>
    </ul>
  </div>
</div>
  

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="rand.html" title="7.15.18. rand"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="prefix_rk_search.html" title="7.15.16. prefix_rk_search"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">Groonga v10.1.1-31-g1e46ba6 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../reference.html" ><span class="section-number">7. </span>Reference manual</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../function.html" accesskey="U"><span class="section-number">7.15. </span>Function</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">7.15.17. </span><code class="docutils literal notranslate"><span class="pre">query</span></code></a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="query">
<h1><span class="section-number">7.15.17. </span><code class="docutils literal notranslate"><span class="pre">query</span></code><a class="headerlink" href="#query" title="Permalink to this headline">¶</a></h1>
<div class="section" id="summary">
<h2><span class="section-number">7.15.17.1. </span>Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">query</span></code> provides <code class="docutils literal notranslate"><span class="pre">--match_columns</span></code> and <code class="docutils literal notranslate"><span class="pre">--query</span></code> parameters of
<a class="reference internal" href="../commands/select.html"><span class="doc">select</span></a> feature as function. You can specify
multiple <code class="docutils literal notranslate"><span class="pre">query</span></code> functions in <code class="docutils literal notranslate"><span class="pre">--filter</span></code> parameter in
<a class="reference internal" href="../commands/select.html"><span class="doc">select</span></a>.</p>
<p>Because of such flexibility, you can control full text search behavior
by combination of multiple <code class="docutils literal notranslate"><span class="pre">query</span></code> functions.</p>
<p><code class="docutils literal notranslate"><span class="pre">query</span></code> can be used in only <code class="docutils literal notranslate"><span class="pre">--filter</span></code> in
<a class="reference internal" href="../commands/select.html"><span class="doc">select</span></a>.</p>
</div>
<div class="section" id="syntax">
<h2><span class="section-number">7.15.17.2. </span>Syntax<a class="headerlink" href="#syntax" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">query</span></code> requires two arguments - <code class="docutils literal notranslate"><span class="pre">match_columns</span></code> and <code class="docutils literal notranslate"><span class="pre">query_string</span></code>.</p>
<p>The parameter <code class="docutils literal notranslate"><span class="pre">query_expander</span></code>, <code class="docutils literal notranslate"><span class="pre">substitution_table</span></code> and
<code class="docutils literal notranslate"><span class="pre">options</span></code> are optional.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>query(match_columns, query_string)
query(match_columns, query_string, query_expander)
query(match_columns, query_string, substitution_table)
query(match_columns, query_string, options)
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">options</span></code> accepts the following keys:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>{
  &quot;expander&quot;: query_expander,
  &quot;default_mode&quot;: default_mode,
  &quot;flags&quot;: flags
}
</pre></div>
</div>
</div>
<div class="section" id="usage">
<h2><span class="section-number">7.15.17.3. </span>Usage<a class="headerlink" href="#usage" title="Permalink to this headline">¶</a></h2>
<p>Here are a schema definition and sample data to show usage.</p>
<p>Sample schema:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>table_create Documents TABLE_NO_KEY
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Documents content COLUMN_SCALAR Text
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Terms TABLE_PAT_KEY ShortText --default_tokenizer TokenBigram  --normalizer NormalizerAuto
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Terms documents_content_index COLUMN_INDEX|WITH_POSITION Documents content
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Users TABLE_NO_KEY
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Users name COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Users memo COLUMN_SCALAR ShortText
# [[0, 1337566253.89858, 0.000355720520019531], true]
table_create Lexicon TABLE_HASH_KEY ShortText \
  --default_tokenizer TokenBigramSplitSymbolAlphaDigit \
  --normalizer NormalizerAuto
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Lexicon users_name COLUMN_INDEX|WITH_POSITION Users name
# [[0, 1337566253.89858, 0.000355720520019531], true]
column_create Lexicon users_memo COLUMN_INDEX|WITH_POSITION Users memo
# [[0, 1337566253.89858, 0.000355720520019531], true]
</pre></div>
</div>
<p>Sample data:</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>load --table Users
[
{&quot;name&quot;: &quot;Alice&quot;, &quot;memo&quot;: &quot;groonga user&quot;},
{&quot;name&quot;: &quot;Alisa&quot;, &quot;memo&quot;: &quot;mroonga user&quot;},
{&quot;name&quot;: &quot;Bob&quot;,   &quot;memo&quot;: &quot;rroonga user&quot;},
{&quot;name&quot;: &quot;Tom&quot;,   &quot;memo&quot;: &quot;nroonga user&quot;},
{&quot;name&quot;: &quot;Tobby&quot;, &quot;memo&quot;: &quot;groonga and mroonga user. mroonga is ...&quot;},
]
# [[0, 1337566253.89858, 0.000355720520019531], 5]
</pre></div>
</div>
<p>Here is the simple usage of <code class="docutils literal notranslate"><span class="pre">query</span></code> function which execute full text
search by keyword ‘alice’ without using <code class="docutils literal notranslate"><span class="pre">--match_columns</span></code> and
<code class="docutils literal notranslate"><span class="pre">--query</span></code> arguments in <code class="docutils literal notranslate"><span class="pre">--filter</span></code>.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select Users --output_columns name,_score --filter &#39;query(&quot;name * 10&quot;, &quot;alice&quot;)&#39;
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         1
#       ],
#       [
#         [
#           &quot;name&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;Alice&quot;,
#         10
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>When executing above query, the keyword <code class="docutils literal notranslate"><span class="pre">alice</span></code> is weighted to the
value <code class="docutils literal notranslate"><span class="pre">10</span></code>.</p>
<p>Here are the contrasting examples with/without <code class="docutils literal notranslate"><span class="pre">query</span></code>.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select Users --output_columns name,memo,_score --match_columns &quot;memo * 10&quot; --query &quot;memo:@groonga OR memo:@mroonga OR memo:@user&quot; --sort_keys -_score
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         5
#       ],
#       [
#         [
#           &quot;name&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;memo&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;Tobby&quot;,
#         &quot;groonga and mroonga user. mroonga is ...&quot;,
#         4
#       ],
#       [
#         &quot;Alice&quot;,
#         &quot;groonga user&quot;,
#         2
#       ],
#       [
#         &quot;Alisa&quot;,
#         &quot;mroonga user&quot;,
#         2
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;rroonga user&quot;,
#         1
#       ],
#       [
#         &quot;Tom&quot;,
#         &quot;nroonga user&quot;,
#         1
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>In this case, the all keywords <code class="docutils literal notranslate"><span class="pre">groonga</span></code>, <code class="docutils literal notranslate"><span class="pre">mroonga</span></code> and <code class="docutils literal notranslate"><span class="pre">user</span></code>
use the default weight. You can’t pass different weight value to each
keyword in this way.</p>
<p>Execution example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>select Users --output_columns name,memo,_score --filter &#39;query(&quot;memo * 10&quot;, &quot;groonga&quot;) || query(&quot;memo * 20&quot;, &quot;mroonga&quot;) || query(&quot;memo * 1&quot;, &quot;user&quot;)&#39; --sort_keys -_score
# [
#   [
#     0,
#     1337566253.89858,
#     0.000355720520019531
#   ],
#   [
#     [
#       [
#         5
#       ],
#       [
#         [
#           &quot;name&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;memo&quot;,
#           &quot;ShortText&quot;
#         ],
#         [
#           &quot;_score&quot;,
#           &quot;Int32&quot;
#         ]
#       ],
#       [
#         &quot;Tobby&quot;,
#         &quot;groonga and mroonga user. mroonga is ...&quot;,
#         51
#       ],
#       [
#         &quot;Alisa&quot;,
#         &quot;mroonga user&quot;,
#         21
#       ],
#       [
#         &quot;Alice&quot;,
#         &quot;groonga user&quot;,
#         11
#       ],
#       [
#         &quot;Tom&quot;,
#         &quot;nroonga user&quot;,
#         1
#       ],
#       [
#         &quot;Bob&quot;,
#         &quot;rroonga user&quot;,
#         1
#       ]
#     ]
#   ]
# ]
</pre></div>
</div>
<p>On the other hand, by specifying multiple <code class="docutils literal notranslate"><span class="pre">query</span></code>, the keywords
<code class="docutils literal notranslate"><span class="pre">groonga</span></code>, <code class="docutils literal notranslate"><span class="pre">mroonga</span></code> and <code class="docutils literal notranslate"><span class="pre">user</span></code> use different weight.</p>
<p>As a result, you can control full text search result score by
specifying different weight to the keywords on your purpose.</p>
</div>
<div class="section" id="parameters">
<h2><span class="section-number">7.15.17.4. </span>Parameters<a class="headerlink" href="#parameters" title="Permalink to this headline">¶</a></h2>
<div class="section" id="required-parameters">
<h3><span class="section-number">7.15.17.4.1. </span>Required parameters<a class="headerlink" href="#required-parameters" title="Permalink to this headline">¶</a></h3>
<p>There are two required parameter, <code class="docutils literal notranslate"><span class="pre">match_columns</span></code> and <code class="docutils literal notranslate"><span class="pre">query_string</span></code>.</p>
<div class="section" id="match-columns">
<h4><span class="section-number">7.15.17.4.1.1. </span><code class="docutils literal notranslate"><span class="pre">match_columns</span></code><a class="headerlink" href="#match-columns" title="Permalink to this headline">¶</a></h4>
<p>Specifies the default target column for fulltext search by
<code class="docutils literal notranslate"><span class="pre">query_string</span></code> parameter value. It is the same role as
<a class="reference internal" href="../commands/select.html#select-match-columns"><span class="std std-ref">match_columns</span></a> parameter in <code class="docutils literal notranslate"><span class="pre">select</span></code>.</p>
</div>
<div class="section" id="query-string">
<h4><span class="section-number">7.15.17.4.1.2. </span><code class="docutils literal notranslate"><span class="pre">query_string</span></code><a class="headerlink" href="#query-string" title="Permalink to this headline">¶</a></h4>
<p>Specifies the search condition in
<a class="reference internal" href="../grn_expr/query_syntax.html"><span class="doc">Query syntax</span></a>. It is the same role as
<code class="docutils literal notranslate"><span class="pre">query</span></code> parameter in <code class="docutils literal notranslate"><span class="pre">select</span></code>.</p>
<p>See <a class="reference internal" href="../commands/select.html#select-match-columns"><span class="std std-ref">match_columns</span></a> about <code class="docutils literal notranslate"><span class="pre">query</span></code> parameter in
<code class="docutils literal notranslate"><span class="pre">select</span></code>.</p>
</div>
</div>
<div class="section" id="optional-parameter">
<h3><span class="section-number">7.15.17.4.2. </span>Optional parameter<a class="headerlink" href="#optional-parameter" title="Permalink to this headline">¶</a></h3>
<p>There are some optional parameters.</p>
<div class="section" id="query-expander">
<h4><span class="section-number">7.15.17.4.2.1. </span><code class="docutils literal notranslate"><span class="pre">query_expander</span></code><a class="headerlink" href="#query-expander" title="Permalink to this headline">¶</a></h4>
<p>Specifies the plugin name for query expansion.</p>
<p>There is one plugin bundled in official release - <a class="reference internal" href="../query_expanders/tsv.html"><span class="doc">QueryExpanderTSV</span></a>.</p>
<p>See <a class="reference internal" href="../query_expanders/tsv.html"><span class="doc">QueryExpanderTSV</span></a> about details.</p>
</div>
<div class="section" id="substitution-table">
<h4><span class="section-number">7.15.17.4.2.2. </span><code class="docutils literal notranslate"><span class="pre">substitution_table</span></code><a class="headerlink" href="#substitution-table" title="Permalink to this headline">¶</a></h4>
<p>Specifies the substitution table and substitution column name
by following format such as <code class="docutils literal notranslate"><span class="pre">${TABLE}.${COLUMN}</span></code> for query expansion.</p>
<p>See <a class="reference internal" href="../commands/select.html#select-query-expander"><span class="std std-ref">query_expander</span></a> about details.</p>
</div>
<div class="section" id="default-mode">
<span id="query-default-mode"></span><h4><span class="section-number">7.15.17.4.2.3. </span><code class="docutils literal notranslate"><span class="pre">default_mode</span></code><a class="headerlink" href="#default-mode" title="Permalink to this headline">¶</a></h4>
<p>Specifies the default search mode. You can custom the default search
mode by <code class="docutils literal notranslate"><span class="pre">column:&#64;keyword</span></code> like syntax. The default search mode is
used when you just specify <code class="docutils literal notranslate"><span class="pre">keyword</span></code> instead of
<code class="docutils literal notranslate"><span class="pre">column:&#64;keyword</span></code>. See <a class="reference internal" href="../grn_expr/query_syntax.html"><span class="doc">Query syntax</span></a> for
more syntax details.</p>
<p>Here are available modes. The default is <code class="docutils literal notranslate"><span class="pre">&quot;MATCH&quot;</span></code> mode. It does
full text search.</p>
<table class="docutils align-default">
<colgroup>
<col style="width: 33%" />
<col style="width: 33%" />
<col style="width: 33%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Mode</p></th>
<th class="head"><p>Aliases</p></th>
<th class="head"><p>Description</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;EQUAL&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;==&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-equal-condition"><span class="std std-ref">Equal condition</span></a> as the default mode.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;NOT_EQUAL&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;!=&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-not-equal-condition"><span class="std std-ref">Not equal condition</span></a> as the default mode.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;LESS&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;&lt;&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-less-than-condition"><span class="std std-ref">Less than condition</span></a> as the default mode.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;GREATER&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;&gt;&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-greater-than-condition"><span class="std std-ref">Greater than condition</span></a> as the default mode.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;LESS_EQUAL&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;&lt;=&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-less-than-or-equal-condition"><span class="std std-ref">Less than or equal to condition</span></a> as the
default mode.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;GREATER_EQUAL&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;&gt;=&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-greater-than-or-equal-condition"><span class="std std-ref">Greater than or equal to condition</span></a> as the
default mode.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;MATCH&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;&#64;&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-full-text-search-condition"><span class="std std-ref">Full text search condition</span></a> as the
default mode.</p>
<p>It’s the default.</p>
</td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;NEAR&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;*N&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-near-search-condition"><span class="std std-ref">Near search condition</span></a> as the default
mode.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;SIMILAR&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;*S&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-similar-search-condition"><span class="std std-ref">Similar search condition</span></a> as the default
mode.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;PREFIX&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;^&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;&#64;^&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-prefix-search-condition"><span class="std std-ref">Prefix search condition</span></a> as the default
mode.</p></td>
</tr>
<tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;SUFFIX&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;$&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;&#64;$&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-suffix-search-condition"><span class="std std-ref">Suffix search condition</span></a> as the default
mode.</p></td>
</tr>
<tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">&quot;REGEXP&quot;</span></code></p></td>
<td><p><code class="docutils literal notranslate"><span class="pre">&quot;~&quot;</span></code>, <code class="docutils literal notranslate"><span class="pre">&quot;&#64;~&quot;</span></code></p></td>
<td><p>It uses <a class="reference internal" href="../grn_expr/query_syntax.html#query-syntax-regular-expression-condition"><span class="std std-ref">Regular expression condition</span></a> as the default
mode.</p></td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="flags">
<h4><span class="section-number">7.15.17.4.2.4. </span><code class="docutils literal notranslate"><span class="pre">flags</span></code><a class="headerlink" href="#flags" title="Permalink to this headline">¶</a></h4>
<p>Specifies the flags that customizes how to parse query.</p>
<p>You can specify multiple flags by separating each flags by <code class="docutils literal notranslate"><span class="pre">|</span></code>. Here
is the example to specify multiple flags:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>query(&quot;title * 10 || content&quot;,
      &quot;keyword&quot;,
      {&quot;flags&quot;: &quot;ALLOW_COLUMN|ALLOW_LEADING_NOT&quot;})
</pre></div>
</div>
<p>See <a class="reference internal" href="../commands/select.html#select-query-flags"><span class="std std-ref">query_flags</span></a> for available flags.</p>
</div>
</div>
</div>
<div class="section" id="return-value">
<h2><span class="section-number">7.15.17.5. </span>Return value<a class="headerlink" href="#return-value" title="Permalink to this headline">¶</a></h2>
<p><code class="docutils literal notranslate"><span class="pre">query</span></code> returns whether any record is matched or not. If one or more
records are matched, it returns <code class="docutils literal notranslate"><span class="pre">true</span></code>. Otherwise, it returns
<code class="docutils literal notranslate"><span class="pre">false</span></code>.</p>
</div>
<div class="section" id="see-also">
<h2><span class="section-number">7.15.17.6. </span>See also<a class="headerlink" href="#see-also" title="Permalink to this headline">¶</a></h2>
<ul class="simple">
<li><p><a class="reference internal" href="../commands/select.html"><span class="doc">select</span></a></p></li>
</ul>
</div>
</div>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../index.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">7.15.17. <code class="docutils literal notranslate"><span class="pre">query</span></code></a><ul>
<li><a class="reference internal" href="#summary">7.15.17.1. Summary</a></li>
<li><a class="reference internal" href="#syntax">7.15.17.2. Syntax</a></li>
<li><a class="reference internal" href="#usage">7.15.17.3. Usage</a></li>
<li><a class="reference internal" href="#parameters">7.15.17.4. Parameters</a><ul>
<li><a class="reference internal" href="#required-parameters">7.15.17.4.1. Required parameters</a><ul>
<li><a class="reference internal" href="#match-columns">7.15.17.4.1.1. <code class="docutils literal notranslate"><span class="pre">match_columns</span></code></a></li>
<li><a class="reference internal" href="#query-string">7.15.17.4.1.2. <code class="docutils literal notranslate"><span class="pre">query_string</span></code></a></li>
</ul>
</li>
<li><a class="reference internal" href="#optional-parameter">7.15.17.4.2. Optional parameter</a><ul>
<li><a class="reference internal" href="#query-expander">7.15.17.4.2.1. <code class="docutils literal notranslate"><span class="pre">query_expander</span></code></a></li>
<li><a class="reference internal" href="#substitution-table">7.15.17.4.2.2. <code class="docutils literal notranslate"><span class="pre">substitution_table</span></code></a></li>
<li><a class="reference internal" href="#default-mode">7.15.17.4.2.3. <code class="docutils literal notranslate"><span class="pre">default_mode</span></code></a></li>
<li><a class="reference internal" href="#flags">7.15.17.4.2.4. <code class="docutils literal notranslate"><span class="pre">flags</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li><a class="reference internal" href="#return-value">7.15.17.5. Return value</a></li>
<li><a class="reference internal" href="#see-also">7.15.17.6. See also</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="prefix_rk_search.html"
                        title="previous chapter"><span class="section-number">7.15.16. </span><code class="docutils literal notranslate"><span class="pre">prefix_rk_search</span></code></a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="rand.html"
                        title="next chapter"><span class="section-number">7.15.18. </span>rand</a></p>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" />
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="rand.html" title="7.15.18. rand"
             >next</a> |</li>
        <li class="right" >
          <a href="prefix_rk_search.html" title="7.15.16. prefix_rk_search"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../index.html">Groonga v10.1.1-31-g1e46ba6 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../reference.html" ><span class="section-number">7. </span>Reference manual</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../function.html" ><span class="section-number">7.15. </span>Function</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href=""><span class="section-number">7.15.17. </span><code class="docutils literal notranslate"><span class="pre">query</span></code></a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2009-2021, Brazil, Inc.
    </div>
  </body>
</html>