| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
.. groonga-command |
| 4 |
.. database: logical_select |
| 5 |
|
| 6 |
``logical_select`` |
| 7 |
================== |
| 8 |
|
| 9 |
Summary |
| 10 |
------- |
| 11 |
|
| 12 |
.. versionadded:: 5.0.5 |
| 13 |
|
| 14 |
``logical_select`` is a sharding version of |
| 15 |
:doc:`select`. ``logical_select`` searches records from multiple |
| 16 |
tables and outputs them. |
| 17 |
|
| 18 |
You need to :doc:`plugin_register` ``sharding`` plugin because |
| 19 |
this command is included in ``sharding`` plugin. |
| 20 |
|
| 21 |
Syntax |
| 22 |
------ |
| 23 |
|
| 24 |
This command takes many parameters. |
| 25 |
|
| 26 |
The required parameters are ``logical_table`` and ``shard_key``. Other |
| 27 |
parameters are optional:: |
| 28 |
|
| 29 |
logical_select logical_table |
| 30 |
shard_key |
| 31 |
[min=null] |
| 32 |
[min_border="include"] |
| 33 |
[max=null] |
| 34 |
[max_border="include"] |
| 35 |
[filter=null] |
| 36 |
[sortby=null] |
| 37 |
[output_columns="_id, _key, *"] |
| 38 |
[offset=0] |
| 39 |
[limit=10] |
| 40 |
[drilldown=null] |
| 41 |
[drilldown_sortby=null] |
| 42 |
[drilldown_output_columns="_key, _nsubrecs"] |
| 43 |
[drilldown_offset=0] |
| 44 |
[drilldown_limit=10] |
| 45 |
[drilldown_calc_types=NONE] |
| 46 |
[drilldown_calc_target=null] |
| 47 |
[sort_keys=null] |
| 48 |
[drilldown_sort_keys=null] |
| 49 |
[match_columns=null] |
| 50 |
[query=null] |
| 51 |
[drilldown_filter=null] |
| 52 |
[post_filter=null] |
| 53 |
[load_table=null] |
| 54 |
[load_columns=null] |
| 55 |
[load_values=null] |
| 56 |
|
| 57 |
There are some parameters that can be only used as named |
| 58 |
parameters. You can't use these parameters as ordered parameters. You |
| 59 |
must specify parameter name. |
| 60 |
|
| 61 |
Here are parameters that can be only used as named parameters: |
| 62 |
|
| 63 |
* ``cache=no`` |
| 64 |
|
| 65 |
This command has the following named parameters for dynamic columns: |
| 66 |
|
| 67 |
* ``columns[${NAME}].stage=null`` |
| 68 |
* ``columns[${NAME}].flags=COLUMN_SCALAR`` |
| 69 |
* ``columns[${NAME}].type=null`` |
| 70 |
* ``columns[${NAME}].value=null`` |
| 71 |
* ``columns[${NAME}].window.sort_keys=null`` |
| 72 |
* ``columns[${NAME}].window.group_keys=null`` |
| 73 |
|
| 74 |
You can use one or more alphabets, digits, ``_`` for ``${NAME}``. For |
| 75 |
example, ``column1`` is a valid ``${NAME}``. This is the same rule as |
| 76 |
normal column. See also :ref:`column-create-name`. |
| 77 |
|
| 78 |
Parameters that have the same ``${NAME}`` are grouped. |
| 79 |
|
| 80 |
For example, the following parameters specify one dynamic column: |
| 81 |
|
| 82 |
* ``--columns[name].stage initial`` |
| 83 |
* ``--columns[name].type UInt32`` |
| 84 |
* ``--columns[name].value 29`` |
| 85 |
|
| 86 |
The following parameters specify two dynamic columns: |
| 87 |
|
| 88 |
* ``--columns[name1].stage initial`` |
| 89 |
* ``--columns[name1].type UInt32`` |
| 90 |
* ``--columns[name1].value 29`` |
| 91 |
* ``--columns[name2].stage filtered`` |
| 92 |
* ``--columns[name2].type Float`` |
| 93 |
* ``--columns[name2].value '_score * 0.1'`` |
| 94 |
|
| 95 |
This command has the following named parameters for advanced |
| 96 |
drilldown: |
| 97 |
|
| 98 |
* ``drilldowns[${LABEL}].keys=null`` |
| 99 |
* ``drilldowns[${LABEL}].sort_keys=null`` |
| 100 |
* ``drilldowns[${LABEL}].output_columns="_key, _nsubrecs"`` |
| 101 |
* ``drilldowns[${LABEL}].offset=0`` |
| 102 |
* ``drilldowns[${LABEL}].limit=10`` |
| 103 |
* ``drilldowns[${LABEL}].calc_types=NONE`` |
| 104 |
* ``drilldowns[${LABEL}].calc_target=null`` |
| 105 |
* ``drilldowns[${LABEL}].filter=null`` |
| 106 |
* ``drilldowns[${LABEL}].columns[${NAME}].stage=null`` |
| 107 |
* ``drilldowns[${LABEL}].columns[${NAME}].flags=COLUMN_SCALAR`` |
| 108 |
* ``drilldowns[${LABEL}].columns[${NAME}].type=null`` |
| 109 |
* ``drilldowns[${LABEL}].columns[${NAME}].value=null`` |
| 110 |
* ``drilldowns[${LABEL}].columns[${NAME}].window.sort_keys=null`` |
| 111 |
* ``drilldowns[${LABEL}].columns[${NAME}].window.group_keys=null`` |
| 112 |
|
| 113 |
.. deprecated:: 6.1.4 |
| 114 |
|
| 115 |
``drilldown[...]`` syntax is deprecated. Use ``drilldowns[...]`` |
| 116 |
instead. |
| 117 |
|
| 118 |
.. deprecated:: 6.1.5 |
| 119 |
|
| 120 |
:ref:`logical-select-drilldowns-label-sortby` is deprecated. |
| 121 |
Use :ref:`logical-select-drilldowns-label-sort-keys` instead. |
| 122 |
|
| 123 |
You can use one or more alphabets, digits, ``_`` and ``.`` for |
| 124 |
``${LABEL}``. For example, ``parent.sub1`` is a valid ``${LABEL}``. |
| 125 |
|
| 126 |
Parameters that have the same ``${LABEL}`` are grouped. |
| 127 |
|
| 128 |
For example, the following parameters specify one drilldown: |
| 129 |
|
| 130 |
* ``--drilldowns[label].keys column`` |
| 131 |
* ``--drilldowns[label].sort_keys -_nsubrecs`` |
| 132 |
|
| 133 |
The following parameters specify two drilldowns: |
| 134 |
|
| 135 |
* ``--drilldowns[label1].keys column1`` |
| 136 |
* ``--drilldowns[label1].sort_keys -_nsubrecs`` |
| 137 |
* ``--drilldowns[label2].keys column2`` |
| 138 |
* ``--drilldowns[label2].sort_keys _key`` |
| 139 |
|
| 140 |
Differences from ``select`` |
| 141 |
--------------------------- |
| 142 |
|
| 143 |
Most of ``logical_select`` features can be used like corresponding |
| 144 |
:doc:`select` features. For example, parameter name is same, output |
| 145 |
format is same and so on. |
| 146 |
|
| 147 |
But there are some differences from :doc:`select`: |
| 148 |
|
| 149 |
* ``logical_table`` and ``shard_key`` parameters are required |
| 150 |
instead of ``table`` parameter. |
| 151 |
* ``sort_keys`` isn't supported when multiple shards are used. (Only |
| 152 |
one shard is used, they are supported. There is one exception |
| 153 |
about ``sort_keys`` for multiple shards. When ``shard_keys`` and |
| 154 |
``sort_keys`` are same, they are supported. See |
| 155 |
:ref:`logical-select-sort-keys` about details) |
| 156 |
* ``_value.${KEY_NAME}`` in ``drilldowns[${LABEL}].sort_keys`` |
| 157 |
doesn't work with multiple shards. It works with one |
| 158 |
shard. ``_key`` in ``drilldowns[${LABEL}].sort_keys`` work with |
| 159 |
multiple shards. |
| 160 |
* ``_value.${KEY_NAME}`` in ``drilldowns[${LABEL}].output_columns`` |
| 161 |
also doesn't work with multiple shards either. It works with one |
| 162 |
shard. |
| 163 |
* ``match_escalation_threshold`` isn't supported yet. |
| 164 |
* ``query_flags`` isn't supported yet. |
| 165 |
* ``query_expander`` isn't supported yet. |
| 166 |
* ``adjuster`` isn't supported yet. |
| 167 |
|
| 168 |
Usage |
| 169 |
----- |
| 170 |
|
| 171 |
Let's learn about usage with examples. This section shows many popular |
| 172 |
usages. |
| 173 |
|
| 174 |
You need to register ``sharding`` plugin because this command is |
| 175 |
included in ``sharding`` plugin. |
| 176 |
|
| 177 |
.. groonga-command |
| 178 |
.. include:: ../../example/reference/commands/logical_select/usage_plugin_register.log |
| 179 |
.. plugin_register sharding |
| 180 |
|
| 181 |
|
| 182 |
Here are a schema definition and sample data to show usage. |
| 183 |
|
| 184 |
.. groonga-command |
| 185 |
.. include:: ../../example/reference/commands/logical_select/usage_setup.log |
| 186 |
.. table_create Entries_20150708 TABLE_HASH_KEY ShortText |
| 187 |
.. column_create Entries_20150708 created_at COLUMN_SCALAR Time |
| 188 |
.. column_create Entries_20150708 content COLUMN_SCALAR Text |
| 189 |
.. column_create Entries_20150708 n_likes COLUMN_SCALAR UInt32 |
| 190 |
.. column_create Entries_20150708 tag COLUMN_SCALAR ShortText |
| 191 |
.. |
| 192 |
.. table_create Entries_20150709 TABLE_HASH_KEY ShortText |
| 193 |
.. column_create Entries_20150709 created_at COLUMN_SCALAR Time |
| 194 |
.. column_create Entries_20150709 content COLUMN_SCALAR Text |
| 195 |
.. column_create Entries_20150709 n_likes COLUMN_SCALAR UInt32 |
| 196 |
.. column_create Entries_20150709 tag COLUMN_SCALAR ShortText |
| 197 |
.. |
| 198 |
.. table_create Terms TABLE_PAT_KEY ShortText \ |
| 199 |
.. --default_tokenizer TokenBigram \ |
| 200 |
.. --normalizer NormalizerAuto |
| 201 |
.. column_create Terms entries_key_index_20150708 \ |
| 202 |
.. COLUMN_INDEX|WITH_POSITION Entries_20150708 _key |
| 203 |
.. column_create Terms entries_content_index_20150708 \ |
| 204 |
.. COLUMN_INDEX|WITH_POSITION Entries_20150708 content |
| 205 |
.. column_create Terms entries_key_index_20150709 \ |
| 206 |
.. COLUMN_INDEX|WITH_POSITION Entries_20150709 _key |
| 207 |
.. column_create Terms entries_content_index_20150709 \ |
| 208 |
.. COLUMN_INDEX|WITH_POSITION Entries_20150709 content |
| 209 |
.. |
| 210 |
.. load --table Entries_20150708 |
| 211 |
.. [ |
| 212 |
.. {"_key": "The first post!", |
| 213 |
.. "created_at": "2015/07/08 00:00:00", |
| 214 |
.. "content": "Welcome! This is my first post!", |
| 215 |
.. "n_likes": 5, |
| 216 |
.. "tag": "Hello"}, |
| 217 |
.. {"_key": "Groonga", |
| 218 |
.. "created_at": "2015/07/08 01:00:00", |
| 219 |
.. "content": "I started to use Groonga. It's very fast!", |
| 220 |
.. "n_likes": 10, |
| 221 |
.. "tag": "Groonga"}, |
| 222 |
.. {"_key": "Mroonga", |
| 223 |
.. "created_at": "2015/07/08 02:00:00", |
| 224 |
.. "content": "I also started to use Mroonga. It's also very fast! Really fast!", |
| 225 |
.. "n_likes": 15, |
| 226 |
.. "tag": "Groonga"} |
| 227 |
.. ] |
| 228 |
.. |
| 229 |
.. load --table Entries_20150709 |
| 230 |
.. [ |
| 231 |
.. {"_key": "Good-bye Senna", |
| 232 |
.. "created_at": "2015/07/09 00:00:00", |
| 233 |
.. "content": "I migrated all Senna system!", |
| 234 |
.. "n_likes": 3, |
| 235 |
.. "tag": "Senna"}, |
| 236 |
.. {"_key": "Good-bye Tritonn", |
| 237 |
.. "created_at": "2015/07/09 01:00:00", |
| 238 |
.. "content": "I also migrated all Tritonn system!", |
| 239 |
.. "n_likes": 3, |
| 240 |
.. "tag": "Senna"} |
| 241 |
.. ] |
| 242 |
|
| 243 |
There are two tables, ``Entries_20150708`` and ``Entries_20150709``, |
| 244 |
for blog entries. |
| 245 |
|
| 246 |
.. note:: |
| 247 |
|
| 248 |
You need to use ``${LOGICAL_TABLE_NAME}_${YYYYMMDD}`` naming rule |
| 249 |
for table names. In this example, ``LOGICAL_TABLE_NAME`` is |
| 250 |
``Entries`` and ``YYYYMMDD`` is ``20150708`` or ``20150709``. |
| 251 |
|
| 252 |
An entry has title, created time, content, the number of likes for the |
| 253 |
entry and tag. Title is key of ``Entries_YYYYMMDD``. Created time is |
| 254 |
value of ``Entries_YYYYMMDD.created_at`` column. Content is value of |
| 255 |
``Entries_YYYYMMDD.content`` column. The number of likes is value of |
| 256 |
``Entries_YYYYMMDD.n_likes`` column. Tag is value of |
| 257 |
``Entries_YYYYMMDD.tag`` column. |
| 258 |
|
| 259 |
``Entries_YYYYMMDD._key`` column and ``Entries_YYYYMMDD.content`` |
| 260 |
column are indexed using ``TokenBigram`` tokenizer. So both |
| 261 |
``Entries_YYYYMMDD._key`` and ``Entries_YYYYMMDD.content`` are |
| 262 |
fulltext search ready. |
| 263 |
|
| 264 |
OK. The schema and data for examples are ready. |
| 265 |
|
| 266 |
Simple usage |
| 267 |
^^^^^^^^^^^^ |
| 268 |
|
| 269 |
Here is an example that specifies only required parameters. |
| 270 |
|
| 271 |
.. groonga-command |
| 272 |
.. include:: ../../example/reference/commands/logical_select/logical_table_existent.log |
| 273 |
.. logical_select --logical_table Entries --shard_key created_at |
| 274 |
|
| 275 |
It is shown that is searched from Entries_20150708 and Entries_20150709 in above example. |
| 276 |
|
| 277 |
Parameters |
| 278 |
---------- |
| 279 |
|
| 280 |
This section describes parameters of ``logical_select``. |
| 281 |
|
| 282 |
Required parameters |
| 283 |
^^^^^^^^^^^^^^^^^^^ |
| 284 |
|
| 285 |
There are required parameters, ``logical_table`` and ``shard_key``. |
| 286 |
|
| 287 |
.. _logical-select-logical-table: |
| 288 |
|
| 289 |
``logical_table`` |
| 290 |
""""""""""""""""" |
| 291 |
|
| 292 |
Specifies logical table name. It means table name without |
| 293 |
``_YYYYMMDD`` postfix. If you use actual table such as |
| 294 |
``Entries_20150708``, ``Entries_20150709`` and so on, logical table |
| 295 |
name is ``Entries``. |
| 296 |
|
| 297 |
You can show 5 records by specifying ``logical_table`` and |
| 298 |
``shard_key`` parameters. They are required parameters. |
| 299 |
|
| 300 |
.. groonga-command |
| 301 |
.. include:: ../../example/reference/commands/logical_select/logical_table_existent.log |
| 302 |
.. logical_select --logical_table Entries --shard_key created_at |
| 303 |
|
| 304 |
If nonexistent table is specified, an error is returned. |
| 305 |
|
| 306 |
.. groonga-command |
| 307 |
.. include:: ../../example/reference/commands/logical_select/logical_table_nonexistent.log |
| 308 |
.. logical_select --logical_table Nonexistent --shard_key created_at |
| 309 |
|
| 310 |
.. _logical-select-shard-key: |
| 311 |
|
| 312 |
``shard_key`` |
| 313 |
""""""""""""" |
| 314 |
|
| 315 |
Specifies column name which is treated as shared key. Shard key is a |
| 316 |
column that stores data that is used for distributing records to |
| 317 |
suitable shards. |
| 318 |
|
| 319 |
Shard key must be ``Time`` type for now. |
| 320 |
|
| 321 |
See :ref:`logical-select-logical-table` how to specify ``shard_key``. |
| 322 |
|
| 323 |
Optional parameters |
| 324 |
^^^^^^^^^^^^^^^^^^^ |
| 325 |
|
| 326 |
There are optional parameters. |
| 327 |
|
| 328 |
.. _logical-select-min: |
| 329 |
|
| 330 |
``min`` |
| 331 |
""""""" |
| 332 |
|
| 333 |
Specifies the minimum value of ``shard_key`` column. If shard doesn't |
| 334 |
have any matched records, the shard isn't searched. |
| 335 |
|
| 336 |
For example, ``min`` is ``"2015/07/09 00:00:00"``, ``Entry_20150708`` |
| 337 |
isn't searched. Because ``Entry_20150708`` has only records for |
| 338 |
``"2015/07/08"``. |
| 339 |
|
| 340 |
The following example only uses ``Entry_20150709`` |
| 341 |
table. ``Entry_20150708`` isn't used. |
| 342 |
|
| 343 |
.. groonga-command |
| 344 |
.. include:: ../../example/reference/commands/logical_select/min.log |
| 345 |
.. logical_select \ |
| 346 |
.. --logical_table Entries \ |
| 347 |
.. --shard_key created_at \ |
| 348 |
.. --min "2015/07/09 00:00:00" |
| 349 |
|
| 350 |
.. _logical-select-min-border: |
| 351 |
|
| 352 |
``min_border`` |
| 353 |
"""""""""""""" |
| 354 |
|
| 355 |
Specifies whether the minimum value is included or not. Here is |
| 356 |
available values. |
| 357 |
|
| 358 |
.. list-table:: |
| 359 |
:header-rows: 1 |
| 360 |
|
| 361 |
* - Value |
| 362 |
- Description |
| 363 |
* - ``include`` |
| 364 |
- Includes ``min`` value. This is the default. |
| 365 |
* - ``exclude`` |
| 366 |
- Doesn't include ``min`` value. |
| 367 |
|
| 368 |
Here is an example for ``exclude``. The result doesn't include the |
| 369 |
``"Good-bye Senna"`` record because its ``created_at`` value is |
| 370 |
``"2015/07/09 00:00:00"``. |
| 371 |
|
| 372 |
.. groonga-command |
| 373 |
.. include:: ../../example/reference/commands/logical_select/min_border.log |
| 374 |
.. logical_select \ |
| 375 |
.. --logical_table Entries \ |
| 376 |
.. --shard_key created_at \ |
| 377 |
.. --min "2015/07/09 00:00:00" \ |
| 378 |
.. --min_border "exclude" |
| 379 |
|
| 380 |
.. _logical-select-max: |
| 381 |
|
| 382 |
``max`` |
| 383 |
""""""" |
| 384 |
|
| 385 |
Specifies the maximum value of ``shard_key`` column. If shard doesn't |
| 386 |
have any matched records, the shard isn't searched. |
| 387 |
|
| 388 |
For example, ``max`` is ``"2015/07/08 23:59:59"``, ``Entry_20150709`` |
| 389 |
isn't searched. Because ``Entry_20150709`` has only records for |
| 390 |
``""2015/07/09"``. |
| 391 |
|
| 392 |
The following example only uses ``Entry_20150708`` |
| 393 |
table. ``Entry_20150709`` isn't used. |
| 394 |
|
| 395 |
.. groonga-command |
| 396 |
.. include:: ../../example/reference/commands/logical_select/max.log |
| 397 |
.. logical_select \ |
| 398 |
.. --logical_table Entries \ |
| 399 |
.. --shard_key created_at \ |
| 400 |
.. --max "2015/07/08 23:59:59" |
| 401 |
|
| 402 |
.. _logical-select-max-border: |
| 403 |
|
| 404 |
``max_border`` |
| 405 |
"""""""""""""" |
| 406 |
|
| 407 |
Specifies whether the maximum value is included or not. Here is |
| 408 |
available values. |
| 409 |
|
| 410 |
.. list-table:: |
| 411 |
:header-rows: 1 |
| 412 |
|
| 413 |
* - Value |
| 414 |
- Description |
| 415 |
* - ``include`` |
| 416 |
- Includes ``max`` value. This is the default. |
| 417 |
* - ``exclude`` |
| 418 |
- Doesn't include ``max`` value. |
| 419 |
|
| 420 |
Here is an example for ``exclude``. The result doesn't include the |
| 421 |
``"Good-bye Senna"`` record because its ``created_at`` value is |
| 422 |
``"2015/07/09 00:00:00"``. |
| 423 |
|
| 424 |
.. groonga-command |
| 425 |
.. include:: ../../example/reference/commands/logical_select/max_border.log |
| 426 |
.. logical_select \ |
| 427 |
.. --logical_table Entries \ |
| 428 |
.. --shard_key created_at \ |
| 429 |
.. --max "2015/07/09 00:00:00" \ |
| 430 |
.. --max_border "exclude" |
| 431 |
|
| 432 |
.. _logical-select-search-related-parameters: |
| 433 |
|
| 434 |
Search related parameters |
| 435 |
^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 436 |
|
| 437 |
This command provides :doc:`select` compatible search related |
| 438 |
parameters. |
| 439 |
|
| 440 |
.. _logical-select-match-columns: |
| 441 |
|
| 442 |
``match_columns`` |
| 443 |
""""""""""""""""" |
| 444 |
|
| 445 |
.. versionadded:: 7.0.1 |
| 446 |
|
| 447 |
Corresponds to :ref:`select-match-columns` in :doc:`select`. See |
| 448 |
:ref:`select-match-columns` for details. |
| 449 |
|
| 450 |
Here is an example to find records that include ``"fast"`` text in |
| 451 |
``content`` column: |
| 452 |
|
| 453 |
.. groonga-command |
| 454 |
.. include:: ../../example/reference/commands/logical_select/match_columns.log |
| 455 |
.. logical_select \ |
| 456 |
.. --logical_table Entries \ |
| 457 |
.. --shard_key created_at \ |
| 458 |
.. --match_columns content \ |
| 459 |
.. --query "fast" |
| 460 |
|
| 461 |
.. _logical-select-query: |
| 462 |
|
| 463 |
``query`` |
| 464 |
""""""""" |
| 465 |
|
| 466 |
.. versionadded:: 7.0.1 |
| 467 |
|
| 468 |
Corresponds to :ref:`select-query` in :doc:`select`. See |
| 469 |
:ref:`select-query` for details. |
| 470 |
|
| 471 |
Here is an example to find records that include ``"fast"`` text in |
| 472 |
``content`` column: |
| 473 |
|
| 474 |
.. groonga-command |
| 475 |
.. include:: ../../example/reference/commands/logical_select/query.log |
| 476 |
.. logical_select \ |
| 477 |
.. --logical_table Entries \ |
| 478 |
.. --shard_key created_at \ |
| 479 |
.. --query "content:@fast" |
| 480 |
|
| 481 |
See also :ref:`logical-select-match-columns`. |
| 482 |
|
| 483 |
.. _logical-select-filter: |
| 484 |
|
| 485 |
``filter`` |
| 486 |
"""""""""" |
| 487 |
|
| 488 |
Corresponds to :ref:`select-filter` in :doc:`select`. See |
| 489 |
:ref:`select-filter` for details. |
| 490 |
|
| 491 |
Here is an example: |
| 492 |
|
| 493 |
.. groonga-command |
| 494 |
.. include:: ../../example/reference/commands/logical_select/filter.log |
| 495 |
.. logical_select \ |
| 496 |
.. --logical_table Entries \ |
| 497 |
.. --shard_key created_at \ |
| 498 |
.. --filter "n_likes <= 5" |
| 499 |
|
| 500 |
.. _logical-select-post-filter: |
| 501 |
|
| 502 |
``post_filter`` |
| 503 |
""""""""""""""" |
| 504 |
|
| 505 |
.. versionadded:: 8.0.1 |
| 506 |
|
| 507 |
Specifies the filter text that is processed after ``filtered`` stage |
| 508 |
dynamic columns are generated. You can use ``post_filter`` to filter |
| 509 |
by ``filtered`` stage dynamic columns. Others are the same as |
| 510 |
:ref:`logical-select-filter`. |
| 511 |
|
| 512 |
Here is an example that shows entries only in popular tag. All target |
| 513 |
entries have ``system`` or ``use`` words: |
| 514 |
|
| 515 |
.. groonga-command |
| 516 |
.. include:: ../../example/reference/commands/logical_select/post_filter.log |
| 517 |
.. logical_select \ |
| 518 |
.. --logical_table Entries \ |
| 519 |
.. --shard_key created_at \ |
| 520 |
.. --columns[n_likes_sum_per_tag].stage filtered \ |
| 521 |
.. --columns[n_likes_sum_per_tag].type UInt32 \ |
| 522 |
.. --columns[n_likes_sum_per_tag].value 'window_sum(n_likes)' \ |
| 523 |
.. --columns[n_likes_sum_per_tag].window.group_keys 'tag' \ |
| 524 |
.. --filter 'content @ "system" || content @ "use"' \ |
| 525 |
.. --post_filter 'n_likes_sum_per_tag > 10' \ |
| 526 |
.. --output_columns _key,n_likes,n_likes_sum_per_tag |
| 527 |
|
| 528 |
.. _logical-select-load-table: |
| 529 |
|
| 530 |
``load_table`` |
| 531 |
"""""""""""""" |
| 532 |
|
| 533 |
.. versionadded:: 8.1.1 |
| 534 |
|
| 535 |
You can store specified a table a result of ``logical_select`` with ``--load_table``, ``--load-columns`` and ``--load_values`` arguments. |
| 536 |
``--load_table`` specifies a table name for storing a result of ``logical_select``. |
| 537 |
|
| 538 |
You must specify a table that already exists. |
| 539 |
|
| 540 |
This argument must use with :ref:`logical-select-load-columns` and :ref:`logical-select-load-values`. |
| 541 |
|
| 542 |
Here is an example that can store ``_id`` and ``timestamp`` that a result of ``logical_select`` in a Logs table specified by ``--load_table``. |
| 543 |
|
| 544 |
.. groonga-command |
| 545 |
.. include:: ../../example/reference/commands/logical_select/load_table.log |
| 546 |
.. table_create Logs_20150203 TABLE_HASH_KEY ShortText |
| 547 |
.. column_create Logs_20150203 timestamp COLUMN_SCALAR Time |
| 548 |
.. table_create Logs_20150204 TABLE_HASH_KEY ShortText |
| 549 |
.. column_create Logs_20150204 timestamp COLUMN_SCALAR Time |
| 550 |
.. |
| 551 |
.. table_create Logs TABLE_HASH_KEY ShortText |
| 552 |
.. column_create Logs original_id COLUMN_SCALAR UInt32 |
| 553 |
.. column_create Logs timestamp_text COLUMN_SCALAR ShortText |
| 554 |
.. |
| 555 |
.. load --table Logs_20150203 |
| 556 |
.. [ |
| 557 |
.. { |
| 558 |
.. "_key": "2015-02-03:1", |
| 559 |
.. "timestamp": "2015-02-03 10:49:00" |
| 560 |
.. }, |
| 561 |
.. { |
| 562 |
.. "_key": "2015-02-03:2", |
| 563 |
.. "timestamp": "2015-02-03 12:49:00" |
| 564 |
.. } |
| 565 |
.. ] |
| 566 |
.. load --table Logs_20150204 |
| 567 |
.. [ |
| 568 |
.. { |
| 569 |
.. "_key": "2015-02-04:1", |
| 570 |
.. "timestamp": "2015-02-04 00:00:00" |
| 571 |
.. } |
| 572 |
.. ] |
| 573 |
.. logical_select \ |
| 574 |
.. --logical_table Logs \ |
| 575 |
.. --shard_key timestamp \ |
| 576 |
.. --load_table Logs \ |
| 577 |
.. --load_columns "_key, original_id, timestamp_text" \ |
| 578 |
.. --load_values "_key, _id, timestamp" |
| 579 |
.. select --table Logs |
| 580 |
|
| 581 |
.. _logical-select-load-columns: |
| 582 |
|
| 583 |
``load_columns`` |
| 584 |
"""""""""""""""" |
| 585 |
|
| 586 |
.. versionadded:: 8.1.1 |
| 587 |
|
| 588 |
Specifies columns of a table that specifying ``--load-table``. |
| 589 |
Stores value of columns that specified with :ref:`logical-select-load-values` in columns that specified with this argument. |
| 590 |
You must specify columns that already exists. |
| 591 |
|
| 592 |
This argument must use with :ref:`logical-select-load-table` and :ref:`logical-select-load-values`. |
| 593 |
|
| 594 |
See example of ``--load_table`` for how to use this argument. |
| 595 |
|
| 596 |
.. _logical-select-load-values: |
| 597 |
|
| 598 |
``load_values`` |
| 599 |
""""""""""""""" |
| 600 |
|
| 601 |
.. versionadded:: 8.1.1 |
| 602 |
|
| 603 |
Specifies columns of result of ``logical_select``. |
| 604 |
Specifies columns for storing values into columns that specified with :ref:`logical-select-load-columns`. |
| 605 |
You must specify columns that already exists. |
| 606 |
|
| 607 |
This argument must use with :ref:`logical-select-load-table` and :ref:`logical-select-load-columns`. |
| 608 |
|
| 609 |
See example of ``--load_table`` for how to use this argument. |
| 610 |
|
| 611 |
.. _logical-select-advanced-search-parameters: |
| 612 |
|
| 613 |
Advanced search parameters |
| 614 |
^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 615 |
|
| 616 |
``logical_select`` doesn't implement advanced search parameters yet. |
| 617 |
|
| 618 |
.. _logical-select-match-escalation-threshold: |
| 619 |
|
| 620 |
``match_escalation_threshold`` |
| 621 |
"""""""""""""""""""""""""""""" |
| 622 |
|
| 623 |
Not implemented yet. |
| 624 |
|
| 625 |
.. _logical-select-query-flags: |
| 626 |
|
| 627 |
``query_flags`` |
| 628 |
""""""""""""""" |
| 629 |
|
| 630 |
Not implemented yet. |
| 631 |
|
| 632 |
.. _logical-select-query-expander: |
| 633 |
|
| 634 |
``query_expander`` |
| 635 |
"""""""""""""""""" |
| 636 |
|
| 637 |
Not implemented yet. |
| 638 |
|
| 639 |
Output related parameters |
| 640 |
^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 641 |
|
| 642 |
.. _logical-select-output-columns: |
| 643 |
|
| 644 |
``output_columns`` |
| 645 |
"""""""""""""""""" |
| 646 |
|
| 647 |
Corresponds to :ref:`select-output-columns` in :doc:`select`. See |
| 648 |
:ref:`select-output-columns` for details. |
| 649 |
|
| 650 |
Here is an example: |
| 651 |
|
| 652 |
.. groonga-command |
| 653 |
.. include:: ../../example/reference/commands/logical_select/output_columns.log |
| 654 |
.. logical_select \ |
| 655 |
.. --logical_table Entries \ |
| 656 |
.. --shard_key created_at \ |
| 657 |
.. --output_columns '_key, *' |
| 658 |
|
| 659 |
.. _logical-select-sortby: |
| 660 |
|
| 661 |
``sortby`` |
| 662 |
"""""""""" |
| 663 |
|
| 664 |
.. deprecated:: 6.1.5 |
| 665 |
|
| 666 |
Use :ref:`logical-select-sort-keys` instead. |
| 667 |
|
| 668 |
.. _logical-select-sort-keys: |
| 669 |
|
| 670 |
``sort_keys`` |
| 671 |
""""""""""""" |
| 672 |
|
| 673 |
Corresponds to :ref:`select-sort-keys` in :doc:`select`. See |
| 674 |
:ref:`select-sort-keys` for details. |
| 675 |
|
| 676 |
``sort_keys`` has a limitation. It works only when the number of |
| 677 |
search target shards is one. If the number of search target shards is |
| 678 |
larger than one, ``sort_keys`` doesn't work. |
| 679 |
|
| 680 |
.. note:: |
| 681 |
|
| 682 |
There is one exception for multiple shards. When the same value is |
| 683 |
specified for ``shard_key`` and ``sort_keys``, they are supported. |
| 684 |
This command processes target shards one by one by ascending |
| 685 |
order. Thus, in this process, magnitude correlation about the value |
| 686 |
of ``shard_key`` is kept among them. This is because ``sort_keys`` |
| 687 |
is supported when ``shard_key`` and ``sort_keys`` is same. |
| 688 |
|
| 689 |
Here is an example that uses only one shard: |
| 690 |
|
| 691 |
.. groonga-command |
| 692 |
.. include:: ../../example/reference/commands/logical_select/sort_keys.log |
| 693 |
.. logical_select \ |
| 694 |
.. --logical_table Entries \ |
| 695 |
.. --shard_key created_at \ |
| 696 |
.. --min "2015/07/08 00:00:00" \ |
| 697 |
.. --min_border "include" \ |
| 698 |
.. --max "2015/07/09 00:00:00" \ |
| 699 |
.. --max_border "exclude" \ |
| 700 |
.. --sort_keys _key |
| 701 |
|
| 702 |
.. _logical-select-offset: |
| 703 |
|
| 704 |
``offset`` |
| 705 |
"""""""""" |
| 706 |
|
| 707 |
Corresponds to :ref:`select-offset` in :doc:`select`. See |
| 708 |
:ref:`select-offset` for details. |
| 709 |
|
| 710 |
Here is an example: |
| 711 |
|
| 712 |
.. groonga-command |
| 713 |
.. include:: ../../example/reference/commands/logical_select/offset.log |
| 714 |
.. logical_select \ |
| 715 |
.. --logical_table Entries \ |
| 716 |
.. --shard_key created_at \ |
| 717 |
.. --offset 2 |
| 718 |
|
| 719 |
.. _logical-select-limit: |
| 720 |
|
| 721 |
``limit`` |
| 722 |
""""""""" |
| 723 |
|
| 724 |
Corresponds to :ref:`select-limit` in :doc:`select`. See |
| 725 |
:ref:`select-limit` for details. |
| 726 |
|
| 727 |
Here is an example: |
| 728 |
|
| 729 |
.. groonga-command |
| 730 |
.. include:: ../../example/reference/commands/logical_select/limit.log |
| 731 |
.. logical_select \ |
| 732 |
.. --logical_table Entries \ |
| 733 |
.. --shard_key created_at \ |
| 734 |
.. --limit 2 |
| 735 |
|
| 736 |
.. _logical-select-scorer: |
| 737 |
|
| 738 |
``scorer`` |
| 739 |
"""""""""" |
| 740 |
|
| 741 |
Not implemented yet. |
| 742 |
|
| 743 |
.. _logical-select-dynamic-column-related-parameters: |
| 744 |
|
| 745 |
Dynamic column related parameters |
| 746 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 747 |
|
| 748 |
.. versionadded:: 7.0.1 |
| 749 |
|
| 750 |
All dynamic column related parameters in :doc:`select` are |
| 751 |
supported. See :ref:`select-dynamic-column-related-parameters` for |
| 752 |
details. |
| 753 |
|
| 754 |
.. _logical-select-columns-name-stage: |
| 755 |
|
| 756 |
``columns[${NAME}].stage`` |
| 757 |
"""""""""""""""""""""""""" |
| 758 |
|
| 759 |
.. versionadded:: 7.0.1 |
| 760 |
|
| 761 |
Corresponds to :ref:`select-columns-name-stage` in :doc:`select`. See |
| 762 |
:ref:`select-columns-name-stage` for details. |
| 763 |
|
| 764 |
This is a required parameter. |
| 765 |
|
| 766 |
Here is an example that creates ``is_popular`` column at ``initial`` |
| 767 |
stage. You can use ``is_popular`` in all parameters such as ``filter`` |
| 768 |
and ``output_columns``: |
| 769 |
|
| 770 |
.. groonga-command |
| 771 |
.. include:: ../../example/reference/commands/logical_select/columns_name_stage.log |
| 772 |
.. logical_select \ |
| 773 |
.. --logical_table Entries \ |
| 774 |
.. --shard_key created_at \ |
| 775 |
.. --columns[is_popular].stage initial \ |
| 776 |
.. --columns[is_popular].type Bool \ |
| 777 |
.. --columns[is_popular].value 'n_likes >= 10' \ |
| 778 |
.. --filter is_popular \ |
| 779 |
.. --output_columns _id,is_popular,n_likes |
| 780 |
|
| 781 |
.. _logical-select-columns-name-flags: |
| 782 |
|
| 783 |
``columns[${NAME}].flags`` |
| 784 |
"""""""""""""""""""""""""" |
| 785 |
|
| 786 |
.. versionadded:: 7.0.1 |
| 787 |
|
| 788 |
Corresponds to :ref:`select-columns-name-flags` in :doc:`select`. See |
| 789 |
:ref:`select-columns-name-flags` for details. |
| 790 |
|
| 791 |
The default value is ``COLUMN_SCALAR``. |
| 792 |
|
| 793 |
Here is an example that creates a vector column by ``COLUMN_VECTOR`` |
| 794 |
flags. ``plugin_register functions/vector`` is for using |
| 795 |
:doc:`/reference/functions/vector_new` function: |
| 796 |
|
| 797 |
.. groonga-command |
| 798 |
.. include:: ../../example/reference/commands/logical_select/columns_name_flags.log |
| 799 |
.. plugin_register functions/vector |
| 800 |
.. logical_select \ |
| 801 |
.. --logical_table Entries \ |
| 802 |
.. --shard_key created_at \ |
| 803 |
.. --columns[vector].stage initial \ |
| 804 |
.. --columns[vector].flags COLUMN_VECTOR \ |
| 805 |
.. --columns[vector].type UInt32 \ |
| 806 |
.. --columns[vector].value 'vector_new(1, 2, 3)' \ |
| 807 |
.. --output_columns _id,vector |
| 808 |
|
| 809 |
.. _logical-select-columns-name-type: |
| 810 |
|
| 811 |
``columns[${NAME}].type`` |
| 812 |
""""""""""""""""""""""""" |
| 813 |
|
| 814 |
.. versionadded:: 7.0.1 |
| 815 |
|
| 816 |
Corresponds to :ref:`select-columns-name-type` in :doc:`select`. See |
| 817 |
:ref:`select-columns-name-type` for details. |
| 818 |
|
| 819 |
This is a required parameter. |
| 820 |
|
| 821 |
Here is an example that creates a ``ShortText`` type column. Stored |
| 822 |
value is casted to ``ShortText`` automatically. In this example, |
| 823 |
number is casted to ``ShortText``: |
| 824 |
|
| 825 |
.. groonga-command |
| 826 |
.. include:: ../../example/reference/commands/logical_select/columns_name_type.log |
| 827 |
.. logical_select \ |
| 828 |
.. --logical_table Entries \ |
| 829 |
.. --shard_key created_at \ |
| 830 |
.. --columns[n_likes_string].stage initial \ |
| 831 |
.. --columns[n_likes_string].type ShortText \ |
| 832 |
.. --columns[n_likes_string].value n_likes \ |
| 833 |
.. --output_columns _id,n_likes,n_likes_string |
| 834 |
|
| 835 |
.. _logical-select-columns-name-value: |
| 836 |
|
| 837 |
``columns[${NAME}].value`` |
| 838 |
"""""""""""""""""""""""""" |
| 839 |
|
| 840 |
.. versionadded:: 7.0.1 |
| 841 |
|
| 842 |
Corresponds to :ref:`select-columns-name-value` in :doc:`select`. See |
| 843 |
:ref:`select-columns-name-value` for details. |
| 844 |
|
| 845 |
You need to specify :doc:`/reference/window_function` as ``value`` |
| 846 |
value and other window function related parameters when you use window |
| 847 |
function. See :ref:`logical-select-window-function-related-parameters` |
| 848 |
for details. |
| 849 |
|
| 850 |
This is a required parameter. |
| 851 |
|
| 852 |
Here is an example that creates a new dynamic column that stores the |
| 853 |
number of characters of content. This example uses |
| 854 |
:doc:`/reference/functions/string_length` function in |
| 855 |
``functions/string`` plugin to compute the number of characters in a |
| 856 |
string. :doc:`plugin_register` is used to register |
| 857 |
``functions/string`` plugin: |
| 858 |
|
| 859 |
.. groonga-command |
| 860 |
.. include:: ../../example/reference/commands/logical_select/columns_name_value.log |
| 861 |
.. plugin_register functions/string |
| 862 |
.. logical_select \ |
| 863 |
.. --logical_table Entries \ |
| 864 |
.. --shard_key created_at \ |
| 865 |
.. --columns[content_length].stage initial \ |
| 866 |
.. --columns[content_length].type UInt32 \ |
| 867 |
.. --columns[content_length].value 'string_length(content)' \ |
| 868 |
.. --output_columns _id,content,content_length |
| 869 |
|
| 870 |
.. _logical-select-window-function-related-parameters: |
| 871 |
|
| 872 |
Window function related parameters |
| 873 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 874 |
|
| 875 |
.. versionadded:: 7.0.1 |
| 876 |
|
| 877 |
All window function related parameters in :doc:`select` are |
| 878 |
supported. See :ref:`select-window-function-related-parameters` for |
| 879 |
details. |
| 880 |
|
| 881 |
.. note:: |
| 882 |
|
| 883 |
Window function over multiple tables aren't supported version 9.0.1 or before. |
| 884 |
Groonga supported it since version 9.0.2 or later. |
| 885 |
However, we need to align the same order for shard key and leading group key or sort key. |
| 886 |
|
| 887 |
For example, we can apply the window function to over multiple tables as below case. |
| 888 |
Because the below example aligns the same order for shard key and leading group key. |
| 889 |
|
| 890 |
The leading group key is ``price`` and shard key is ``timestamp`` in the below example. |
| 891 |
We can apply the window function to over multiple tables in the below example. |
| 892 |
Because ``price`` and ``timestamp`` aligns the same order. |
| 893 |
|
| 894 |
.. groonga-command |
| 895 |
.. include:: ../../example/reference/commands/logical_select/window_function_for_over_shard.log |
| 896 |
.. plugin_register sharding |
| 897 |
.. |
| 898 |
.. table_create ItemLogs_20170415 TABLE_NO_KEY |
| 899 |
.. column_create ItemLogs_20170415 timestamp COLUMN_SCALAR Time |
| 900 |
.. column_create ItemLogs_20170415 price COLUMN_SCALAR UInt32 |
| 901 |
.. column_create ItemLogs_20170415 n_likes COLUMN_SCALAR UInt32 |
| 902 |
.. |
| 903 |
.. table_create ItemLogs_20170416 TABLE_NO_KEY |
| 904 |
.. column_create ItemLogs_20170416 timestamp COLUMN_SCALAR Time |
| 905 |
.. column_create ItemLogs_20170416 price COLUMN_SCALAR UInt32 |
| 906 |
.. column_create ItemLogs_20170416 n_likes COLUMN_SCALAR UInt32 |
| 907 |
.. |
| 908 |
.. load --table ItemLogs_20170415 |
| 909 |
.. [ |
| 910 |
.. {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100}, |
| 911 |
.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100}, |
| 912 |
.. {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200} |
| 913 |
.. ] |
| 914 |
.. |
| 915 |
.. load --table ItemLogs_20170416 |
| 916 |
.. [ |
| 917 |
.. {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200}, |
| 918 |
.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300}, |
| 919 |
.. {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300} |
| 920 |
.. ] |
| 921 |
.. |
| 922 |
.. logical_select ItemLogs \ |
| 923 |
.. --shard_key timestamp \ |
| 924 |
.. --columns[count].stage initial \ |
| 925 |
.. --columns[count].type UInt32 \ |
| 926 |
.. --columns[count].flags COLUMN_SCALAR \ |
| 927 |
.. --columns[count].value 'window_count()' \ |
| 928 |
.. --columns[count].window.group_keys price \ |
| 929 |
.. --output_columns price,count |
| 930 |
|
| 931 |
.. _logical-select-columns-name-window-sort-keys: |
| 932 |
|
| 933 |
``columns[${NAME}].window.sort_keys`` |
| 934 |
""""""""""""""""""""""""""""""""""""" |
| 935 |
|
| 936 |
.. versionadded:: 7.0.1 |
| 937 |
|
| 938 |
Corresponds to :ref:`select-columns-name-window-sort-keys` in |
| 939 |
:doc:`select`. See :ref:`select-columns-name-window-sort-keys` for |
| 940 |
details. |
| 941 |
|
| 942 |
You must specify :ref:`logical-select-columns-name-window-sort-keys` |
| 943 |
or :ref:`logical-select-columns-name-window-group-keys` to use window |
| 944 |
function. |
| 945 |
|
| 946 |
Here is an example that computes cumulative sum per |
| 947 |
``Entries.tag``. Each group is sorted by ``Entries._key``: |
| 948 |
|
| 949 |
.. groonga-command |
| 950 |
.. include:: ../../example/reference/commands/logical_select/columns_name_window_sort_keys.log |
| 951 |
.. logical_select \ |
| 952 |
.. --logical_table Entries \ |
| 953 |
.. --shard_key created_at \ |
| 954 |
.. --columns[n_likes_cumulative_sum_per_tag].stage initial \ |
| 955 |
.. --columns[n_likes_cumulative_sum_per_tag].type UInt32 \ |
| 956 |
.. --columns[n_likes_cumulative_sum_per_tag].value 'window_sum(n_likes)' \ |
| 957 |
.. --columns[n_likes_cumulative_sum_per_tag].window.sort_keys _key \ |
| 958 |
.. --columns[n_likes_cumulative_sum_per_tag].window.group_keys tag \ |
| 959 |
.. --sort_keys _key \ |
| 960 |
.. --output_columns tag,_key,n_likes,n_likes_cumulative_sum_per_tag |
| 961 |
|
| 962 |
.. _logical-select-columns-name-window-group-keys: |
| 963 |
|
| 964 |
``columns[${NAME}].window.group_keys`` |
| 965 |
"""""""""""""""""""""""""""""""""""""" |
| 966 |
|
| 967 |
.. versionadded:: 7.0.1 |
| 968 |
|
| 969 |
Corresponds to :ref:`select-columns-name-window-group-keys` in |
| 970 |
:doc:`select`. See :ref:`select-columns-name-window-group-keys` for |
| 971 |
details. |
| 972 |
|
| 973 |
You must specify :ref:`logical-select-columns-name-window-sort-keys` |
| 974 |
or :ref:`logical-select-columns-name-window-group-keys` to use window |
| 975 |
function. |
| 976 |
|
| 977 |
Here is an example that computes sum per ``Entries.tag``: |
| 978 |
|
| 979 |
.. groonga-command |
| 980 |
.. include:: ../../example/reference/commands/logical_select/columns_name_window_group_keys.log |
| 981 |
.. logical_select \ |
| 982 |
.. --logical_table Entries \ |
| 983 |
.. --shard_key created_at \ |
| 984 |
.. --columns[n_likes_sum_per_tag].stage initial \ |
| 985 |
.. --columns[n_likes_sum_per_tag].type UInt32 \ |
| 986 |
.. --columns[n_likes_sum_per_tag].value 'window_sum(n_likes)' \ |
| 987 |
.. --columns[n_likes_sum_per_tag].window.group_keys tag \ |
| 988 |
.. --sort_keys _key \ |
| 989 |
.. --output_columns tag,_key,n_likes,n_likes_sum_per_tag |
| 990 |
|
| 991 |
.. _logical-select-drilldown-related-parameters: |
| 992 |
|
| 993 |
Drilldown related parameters |
| 994 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 995 |
|
| 996 |
All drilldown related parameters in :doc:`select` are supported. See |
| 997 |
:ref:`select-drilldown-related-parameters` for details. |
| 998 |
|
| 999 |
.. _logical-select-drilldown: |
| 1000 |
|
| 1001 |
``drilldown`` |
| 1002 |
""""""""""""" |
| 1003 |
|
| 1004 |
Corresponds to :ref:`select-drilldown` in :doc:`select`. See |
| 1005 |
:ref:`select-drilldown` for details. |
| 1006 |
|
| 1007 |
Here is an example: |
| 1008 |
|
| 1009 |
.. groonga-command |
| 1010 |
.. include:: ../../example/reference/commands/logical_select/drilldown.log |
| 1011 |
.. logical_select \ |
| 1012 |
.. --logical_table Entries \ |
| 1013 |
.. --shard_key created_at \ |
| 1014 |
.. --output_columns _key,tag \ |
| 1015 |
.. --drilldown tag |
| 1016 |
|
| 1017 |
.. _logical-select-drilldown-sortby: |
| 1018 |
|
| 1019 |
``drilldown_sortby`` |
| 1020 |
"""""""""""""""""""" |
| 1021 |
|
| 1022 |
.. deprecated:: 6.1.5 |
| 1023 |
|
| 1024 |
Use :ref:`logical-select-drilldown-sort-keys` instead. |
| 1025 |
|
| 1026 |
.. _logical-select-drilldown-sort-keys: |
| 1027 |
|
| 1028 |
``drilldown_sort_keys`` |
| 1029 |
""""""""""""""""""""""" |
| 1030 |
|
| 1031 |
Corresponds to :ref:`select-drilldown-sort-keys` in :doc:`select`. See |
| 1032 |
:ref:`select-drilldown-sort-keys` for details. |
| 1033 |
|
| 1034 |
Here is an example: |
| 1035 |
|
| 1036 |
.. groonga-command |
| 1037 |
.. include:: ../../example/reference/commands/logical_select/drilldown_sort_keys.log |
| 1038 |
.. logical_select \ |
| 1039 |
.. --logical_table Entries \ |
| 1040 |
.. --shard_key created_at \ |
| 1041 |
.. --limit 0 \ |
| 1042 |
.. --output_columns _id \ |
| 1043 |
.. --drilldown tag \ |
| 1044 |
.. --drilldown_sort_keys -_nsubrecs,_key |
| 1045 |
|
| 1046 |
.. _logical-select-drilldown-output-columns: |
| 1047 |
|
| 1048 |
``drilldown_output_columns`` |
| 1049 |
"""""""""""""""""""""""""""" |
| 1050 |
|
| 1051 |
Corresponds to :ref:`select-drilldown-output-columns` in |
| 1052 |
:doc:`select`. See :ref:`select-drilldown-output-columns` for details. |
| 1053 |
|
| 1054 |
Here is an example: |
| 1055 |
|
| 1056 |
.. groonga-command |
| 1057 |
.. include:: ../../example/reference/commands/logical_select/drilldown_output_columns.log |
| 1058 |
.. logical_select \ |
| 1059 |
.. --logical_table Entries \ |
| 1060 |
.. --shard_key created_at \ |
| 1061 |
.. --limit 0 \ |
| 1062 |
.. --output_columns _id \ |
| 1063 |
.. --drilldown tag \ |
| 1064 |
.. --drilldown_output_columns _key |
| 1065 |
|
| 1066 |
.. _logical-select-drilldown-offset: |
| 1067 |
|
| 1068 |
``drilldown_offset`` |
| 1069 |
"""""""""""""""""""" |
| 1070 |
|
| 1071 |
Corresponds to :ref:`select-drilldown-offset` in :doc:`select`. See |
| 1072 |
:ref:`select-drilldown-offset` for details. |
| 1073 |
|
| 1074 |
Here is an example: |
| 1075 |
|
| 1076 |
.. groonga-command |
| 1077 |
.. include:: ../../example/reference/commands/logical_select/drilldown_offset.log |
| 1078 |
.. logical_select \ |
| 1079 |
.. --logical_table Entries \ |
| 1080 |
.. --shard_key created_at \ |
| 1081 |
.. --limit 0 \ |
| 1082 |
.. --output_columns _id \ |
| 1083 |
.. --drilldown tag \ |
| 1084 |
.. --drilldown_offset 1 |
| 1085 |
|
| 1086 |
.. _logical-select-drilldown-limit: |
| 1087 |
|
| 1088 |
``drilldown_limit`` |
| 1089 |
""""""""""""""""""" |
| 1090 |
|
| 1091 |
Corresponds to :ref:`select-drilldown-limit` in :doc:`select`. See |
| 1092 |
:ref:`select-drilldown-limit` for details. |
| 1093 |
|
| 1094 |
Here is an example: |
| 1095 |
|
| 1096 |
.. groonga-command |
| 1097 |
.. include:: ../../example/reference/commands/logical_select/drilldown_limit.log |
| 1098 |
.. logical_select \ |
| 1099 |
.. --logical_table Entries \ |
| 1100 |
.. --shard_key created_at \ |
| 1101 |
.. --limit 0 \ |
| 1102 |
.. --output_columns _id \ |
| 1103 |
.. --drilldown tag \ |
| 1104 |
.. --drilldown_limit 2 |
| 1105 |
|
| 1106 |
.. _logical-select-drilldown-calc-types: |
| 1107 |
|
| 1108 |
``drilldown_calc_types`` |
| 1109 |
"""""""""""""""""""""""" |
| 1110 |
|
| 1111 |
Corresponds to :ref:`select-drilldown-calc-types` in |
| 1112 |
:doc:`select`. See :ref:`select-drilldown-calc-types` for details. |
| 1113 |
|
| 1114 |
Here is an example: |
| 1115 |
|
| 1116 |
.. groonga-command |
| 1117 |
.. include:: ../../example/reference/commands/logical_select/drilldown_calc_types.log |
| 1118 |
.. logical_select \ |
| 1119 |
.. --logical_table Entries \ |
| 1120 |
.. --shard_key created_at \ |
| 1121 |
.. --limit -1 \ |
| 1122 |
.. --output_columns tag,n_likes \ |
| 1123 |
.. --drilldown tag \ |
| 1124 |
.. --drilldown_calc_types MAX,MIN,SUM,AVG \ |
| 1125 |
.. --drilldown_calc_target n_likes \ |
| 1126 |
.. --drilldown_output_columns _key,_nsubrecs,_max,_min,_sum,_avg |
| 1127 |
|
| 1128 |
.. _logical-select-drilldown-calc-target: |
| 1129 |
|
| 1130 |
``drilldown_calc_target`` |
| 1131 |
""""""""""""""""""""""""" |
| 1132 |
|
| 1133 |
Corresponds to :ref:`select-drilldown-calc-target` in |
| 1134 |
:doc:`select`. See :ref:`select-drilldown-calc-target` for details. |
| 1135 |
|
| 1136 |
See also :ref:`logical-select-drilldown-calc-types` for an example. |
| 1137 |
|
| 1138 |
.. _logical-select-drilldown-filter: |
| 1139 |
|
| 1140 |
``drilldown_filter`` |
| 1141 |
"""""""""""""""""""" |
| 1142 |
|
| 1143 |
.. versionadded:: 7.0.1 |
| 1144 |
|
| 1145 |
Corresponds to :ref:`select-drilldown-filter` in |
| 1146 |
:doc:`select`. See :ref:`select-drilldown-filter` for details. |
| 1147 |
|
| 1148 |
Here is an example to suppress drilled down tags that are occurred |
| 1149 |
only once: |
| 1150 |
|
| 1151 |
.. groonga-command |
| 1152 |
.. include:: ../../example/reference/commands/logical_select/drilldown_filter.log |
| 1153 |
.. logical_select \ |
| 1154 |
.. --logical_table Entries \ |
| 1155 |
.. --shard_key created_at \ |
| 1156 |
.. --limit 0 \ |
| 1157 |
.. --output_columns _id \ |
| 1158 |
.. --drilldown tag \ |
| 1159 |
.. --drilldown_filter "_nsubrecs > 1" \ |
| 1160 |
.. --drilldown_output_columns _key,_nsubrecs |
| 1161 |
|
| 1162 |
.. _logical-select-advanced-drilldown-related-parameters: |
| 1163 |
|
| 1164 |
Advanced drilldown related parameters |
| 1165 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 1166 |
|
| 1167 |
All advanced drilldown related parameters in :doc:`select` are |
| 1168 |
supported. See :ref:`select-advanced-drilldown-related-parameters` for |
| 1169 |
details. |
| 1170 |
|
| 1171 |
There are some limitations: |
| 1172 |
|
| 1173 |
* ``_value.${KEY_NAME}`` in ``drilldowns[${LABEL}].sort_keys`` |
| 1174 |
doesn't work with multiple shards. It works with one |
| 1175 |
shard. ``_key`` in ``drilldowns[${LABEL}].sort_key`` work with |
| 1176 |
multiple shards. |
| 1177 |
|
| 1178 |
.. _logical-select-drilldowns-label-keys: |
| 1179 |
|
| 1180 |
``drilldowns[${LABEL}].keys`` |
| 1181 |
""""""""""""""""""""""""""""" |
| 1182 |
|
| 1183 |
Corresponds to :ref:`select-drilldowns-label-keys` in |
| 1184 |
:doc:`select`. See :ref:`select-drilldowns-label-keys` for details. |
| 1185 |
|
| 1186 |
Here is an example: |
| 1187 |
|
| 1188 |
.. groonga-command |
| 1189 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_keys.log |
| 1190 |
.. logical_select \ |
| 1191 |
.. --logical_table Entries \ |
| 1192 |
.. --shard_key created_at \ |
| 1193 |
.. --limit 0 \ |
| 1194 |
.. --output_columns _id \ |
| 1195 |
.. --drilldowns[tag.n_likes].keys tag,n_likes \ |
| 1196 |
.. --drilldowns[tag.n_likes].output_columns _value.tag,_value.n_likes,_nsubrecs |
| 1197 |
|
| 1198 |
.. _logical-select-drilldowns-label-output-columns: |
| 1199 |
|
| 1200 |
``drilldowns[${LABEL}].output_columns`` |
| 1201 |
""""""""""""""""""""""""""""""""""""""" |
| 1202 |
|
| 1203 |
Corresponds to :ref:`select-drilldowns-label-output-columns` in |
| 1204 |
:doc:`select`. See :ref:`select-drilldowns-label-output-columns` for |
| 1205 |
details. |
| 1206 |
|
| 1207 |
``drilldowns[${LABEL}].output_columns`` has a limitation. |
| 1208 |
|
| 1209 |
``_value.${KEY_NAME}`` in ``drilldowns[${LABEL}].output_columns`` doesn't |
| 1210 |
work with multiple shards. It works with one shard. |
| 1211 |
|
| 1212 |
Here is an example: |
| 1213 |
|
| 1214 |
.. groonga-command |
| 1215 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_output_columns.log |
| 1216 |
.. logical_select \ |
| 1217 |
.. --logical_table Entries \ |
| 1218 |
.. --shard_key created_at \ |
| 1219 |
.. --limit 0 \ |
| 1220 |
.. --output_columns _id \ |
| 1221 |
.. --drilldowns[tag].keys tag \ |
| 1222 |
.. --drilldowns[tag].output_columns _key,_nsubrecs |
| 1223 |
|
| 1224 |
.. _logical-select-drilldowns-label-sortby: |
| 1225 |
|
| 1226 |
``drilldowns[${LABEL}].sortby`` |
| 1227 |
""""""""""""""""""""""""""""""" |
| 1228 |
|
| 1229 |
.. deprecated:: 6.1.5 |
| 1230 |
|
| 1231 |
Use :ref:`logical-select-drilldowns-label-sort-keys` instead. |
| 1232 |
|
| 1233 |
.. _logical-select-drilldowns-label-sort-keys: |
| 1234 |
|
| 1235 |
``drilldowns[${LABEL}].sort_keys`` |
| 1236 |
"""""""""""""""""""""""""""""""""" |
| 1237 |
|
| 1238 |
Corresponds to :ref:`logical-select-drilldown-sort-keys` in not |
| 1239 |
labeled drilldown. |
| 1240 |
|
| 1241 |
``drilldowns[${LABEL}].sort_keys`` has a limitation. |
| 1242 |
|
| 1243 |
``_value.${KEY_NAME}`` in ``drilldowns[${LABEL}].sort_keys`` doesn't |
| 1244 |
work with multiple shards. It works with one shard. ``_key`` in |
| 1245 |
``drilldowns[${LABEL}].sort_keys`` work with multiple shards. |
| 1246 |
|
| 1247 |
Here is an example that uses ``_value.${KEY_NAME}`` with only one |
| 1248 |
shard: |
| 1249 |
|
| 1250 |
.. groonga-command |
| 1251 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_sort_keys.log |
| 1252 |
.. logical_select \ |
| 1253 |
.. --logical_table Entries \ |
| 1254 |
.. --shard_key created_at \ |
| 1255 |
.. --min "2015/07/08 00:00:00" \ |
| 1256 |
.. --min_border "include" \ |
| 1257 |
.. --max "2015/07/09 00:00:00" \ |
| 1258 |
.. --max_border "exclude" \ |
| 1259 |
.. --limit 0 \ |
| 1260 |
.. --output_columns _id \ |
| 1261 |
.. --drilldowns[tag.n_likes].keys tag,n_likes \ |
| 1262 |
.. --drilldowns[tag.n_likes].output_columns _nsubrecs,_value.n_likes,_value.tag \ |
| 1263 |
.. --drilldowns[tag.n_likes].sort_keys -_nsubrecs,_value.n_likes,_value.tag |
| 1264 |
|
| 1265 |
.. _logical-select-drilldowns-label-offset: |
| 1266 |
|
| 1267 |
``drilldowns[${LABEL}].offset`` |
| 1268 |
""""""""""""""""""""""""""""""" |
| 1269 |
|
| 1270 |
Corresponds to :ref:`logical-select-drilldown-offset` in not labeled |
| 1271 |
drilldown. |
| 1272 |
|
| 1273 |
Here is an example: |
| 1274 |
|
| 1275 |
.. groonga-command |
| 1276 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_offset.log |
| 1277 |
.. logical_select \ |
| 1278 |
.. --logical_table Entries \ |
| 1279 |
.. --shard_key created_at \ |
| 1280 |
.. --limit 0 \ |
| 1281 |
.. --output_columns _id \ |
| 1282 |
.. --drilldowns[tag.n_likes].keys tag \ |
| 1283 |
.. --drilldowns[tag.n_likes].offset 1 |
| 1284 |
|
| 1285 |
.. _logical-select-drilldowns-label-limit: |
| 1286 |
|
| 1287 |
``drilldowns[${LABEL}].limit`` |
| 1288 |
"""""""""""""""""""""""""""""" |
| 1289 |
|
| 1290 |
Corresponds to :ref:`logical-select-drilldown-limit` in not labeled |
| 1291 |
drilldown. |
| 1292 |
|
| 1293 |
Here is an example: |
| 1294 |
|
| 1295 |
.. groonga-command |
| 1296 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_limit.log |
| 1297 |
.. logical_select \ |
| 1298 |
.. --logical_table Entries \ |
| 1299 |
.. --shard_key created_at \ |
| 1300 |
.. --limit 0 \ |
| 1301 |
.. --output_columns _id \ |
| 1302 |
.. --drilldowns[tag.n_likes].keys tag \ |
| 1303 |
.. --drilldowns[tag.n_likes].limit 2 |
| 1304 |
|
| 1305 |
.. _logical-select-drilldowns-label-calc-types: |
| 1306 |
|
| 1307 |
``drilldowns[${LABEL}].calc_types`` |
| 1308 |
""""""""""""""""""""""""""""""""""" |
| 1309 |
|
| 1310 |
Corresponds to :ref:`logical-select-drilldown-calc-types` in not |
| 1311 |
labeled drilldown. |
| 1312 |
|
| 1313 |
Here is an example: |
| 1314 |
|
| 1315 |
.. groonga-command |
| 1316 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_calc_types.log |
| 1317 |
.. logical_select \ |
| 1318 |
.. --logical_table Entries \ |
| 1319 |
.. --shard_key created_at \ |
| 1320 |
.. --limit 0 \ |
| 1321 |
.. --output_columns _id \ |
| 1322 |
.. --drilldowns[tag].keys tag \ |
| 1323 |
.. --drilldowns[tag].calc_types MAX,MIN,SUM,AVG \ |
| 1324 |
.. --drilldowns[tag].calc_target n_likes \ |
| 1325 |
.. --drilldowns[tag].output_columns _key,_nsubrecs,_max,_min,_sum,_avg |
| 1326 |
|
| 1327 |
.. _logical-select-drilldowns-label-calc-target: |
| 1328 |
|
| 1329 |
``drilldowns[${LABEL}].calc_target`` |
| 1330 |
"""""""""""""""""""""""""""""""""""" |
| 1331 |
|
| 1332 |
Corresponds to :ref:`logical-select-drilldown-calc-target` in not |
| 1333 |
labeled drilldown. |
| 1334 |
|
| 1335 |
See also :ref:`logical-select-drilldowns-label-calc-types` |
| 1336 |
for an example. |
| 1337 |
|
| 1338 |
.. _logical-select-drilldowns-label-filter: |
| 1339 |
|
| 1340 |
``drilldowns[${LABEL}].filter`` |
| 1341 |
""""""""""""""""""""""""""""""" |
| 1342 |
|
| 1343 |
.. versionadded:: 7.0.1 |
| 1344 |
|
| 1345 |
Corresponds to :ref:`logical-select-drilldown-filter` in not labeled |
| 1346 |
drilldown. |
| 1347 |
|
| 1348 |
Here is an example to suppress drilled down tags that are occurred |
| 1349 |
only once: |
| 1350 |
|
| 1351 |
.. groonga-command |
| 1352 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_filter.log |
| 1353 |
.. logical_select \ |
| 1354 |
.. --logical_table Entries \ |
| 1355 |
.. --shard_key created_at \ |
| 1356 |
.. --limit 0 \ |
| 1357 |
.. --output_columns _id \ |
| 1358 |
.. --drilldowns[tag].keys tag \ |
| 1359 |
.. --drilldowns[tag].filter "_nsubrecs > 1" \ |
| 1360 |
.. --drilldowns[tag].output_columns _key,_nsubrecs |
| 1361 |
|
| 1362 |
.. _logical-select-drilldowns-label-columns-name-stage: |
| 1363 |
|
| 1364 |
``drilldowns[${LABEL}].columns[${NAME}].stage`` |
| 1365 |
""""""""""""""""""""""""""""""""""""""""""""""" |
| 1366 |
|
| 1367 |
.. versionadded:: 7.0.1 |
| 1368 |
|
| 1369 |
Corresponds to :ref:`select-drilldowns-label-columns-name-stage` in |
| 1370 |
:doc:`select`. See :ref:`select-drilldowns-label-columns-name-stage` |
| 1371 |
for details. |
| 1372 |
|
| 1373 |
Here is an example that creates a dynamic column at ``initial`` |
| 1374 |
stage. This example creates a dynamic column that stores whether each |
| 1375 |
drilled down tag is occurred only once or not: |
| 1376 |
|
| 1377 |
.. groonga-command |
| 1378 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_columns_name_stage.log |
| 1379 |
.. logical_select \ |
| 1380 |
.. --logical_table Entries \ |
| 1381 |
.. --shard_key created_at \ |
| 1382 |
.. --limit 0 \ |
| 1383 |
.. --output_columns _id \ |
| 1384 |
.. --drilldowns[tag].keys tag \ |
| 1385 |
.. --drilldowns[tag].columns[is_popular].stage initial \ |
| 1386 |
.. --drilldowns[tag].columns[is_popular].type Bool \ |
| 1387 |
.. --drilldowns[tag].columns[is_popular].value '_nsubrecs > 1' \ |
| 1388 |
.. --drilldowns[tag].output_columns _key,_nsubrecs,is_popular |
| 1389 |
|
| 1390 |
.. _logical-select-drilldowns-label-columns-name-flags: |
| 1391 |
|
| 1392 |
``drilldowns[${LABEL}].columns[${NAME}].flags`` |
| 1393 |
""""""""""""""""""""""""""""""""""""""""""""""" |
| 1394 |
|
| 1395 |
.. versionadded:: 7.0.1 |
| 1396 |
|
| 1397 |
Corresponds to :ref:`logical-select-columns-name-flags` in main |
| 1398 |
search. |
| 1399 |
|
| 1400 |
The default value is ``COLUMN_SCALAR``. |
| 1401 |
|
| 1402 |
Here is an example that creates a vector column by ``COLUMN_VECTOR`` |
| 1403 |
flags. ``plugin_register functions/vector`` is for using |
| 1404 |
:doc:`/reference/functions/vector_new` function: |
| 1405 |
|
| 1406 |
.. groonga-command |
| 1407 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_columns_name_flags.log |
| 1408 |
.. logical_select \ |
| 1409 |
.. --logical_table Entries \ |
| 1410 |
.. --shard_key created_at \ |
| 1411 |
.. --limit 0 \ |
| 1412 |
.. --output_columns _id \ |
| 1413 |
.. --drilldowns[tag].keys tag \ |
| 1414 |
.. --drilldowns[tag].columns[vector].stage initial \ |
| 1415 |
.. --drilldowns[tag].columns[vector].flags COLUMN_VECTOR \ |
| 1416 |
.. --drilldowns[tag].columns[vector].type ShortText \ |
| 1417 |
.. --drilldowns[tag].columns[vector].value 'vector_new("a", "b", "c")' \ |
| 1418 |
.. --drilldowns[tag].output_columns _key,vector |
| 1419 |
|
| 1420 |
.. _logical-select-drilldowns-label-columns-name-type: |
| 1421 |
|
| 1422 |
``drilldowns[${LABEL}].columns[${NAME}].type`` |
| 1423 |
"""""""""""""""""""""""""""""""""""""""""""""" |
| 1424 |
|
| 1425 |
.. versionadded:: 7.0.1 |
| 1426 |
|
| 1427 |
Corresponds to :ref:`logical-select-columns-name-type` in main |
| 1428 |
search. |
| 1429 |
|
| 1430 |
This is a required parameter. |
| 1431 |
|
| 1432 |
Here is an example that creates a ``ShortText`` type column. Stored |
| 1433 |
value is casted to ``ShortText`` automatically. In this example, |
| 1434 |
number is casted to ``ShortText``: |
| 1435 |
|
| 1436 |
.. groonga-command |
| 1437 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_columns_name_type.log |
| 1438 |
.. logical_select \ |
| 1439 |
.. --logical_table Entries \ |
| 1440 |
.. --shard_key created_at \ |
| 1441 |
.. --limit 0 \ |
| 1442 |
.. --output_columns _id \ |
| 1443 |
.. --drilldowns[tag].keys tag \ |
| 1444 |
.. --drilldowns[tag].columns[nsubrecs_string].stage initial \ |
| 1445 |
.. --drilldowns[tag].columns[nsubrecs_string].type ShortText \ |
| 1446 |
.. --drilldowns[tag].columns[nsubrecs_string].value _nsubrecs \ |
| 1447 |
.. --drilldowns[tag].output_columns _key,_nsubrecs,nsubrecs_string |
| 1448 |
|
| 1449 |
.. _logical-select-drilldowns-label-columns-name-value: |
| 1450 |
|
| 1451 |
``drilldowns[${LABEL}].columns[${NAME}].value`` |
| 1452 |
""""""""""""""""""""""""""""""""""""""""""""""" |
| 1453 |
|
| 1454 |
.. versionadded:: 7.0.1 |
| 1455 |
|
| 1456 |
Corresponds to :ref:`logical-select-columns-name-value` in main |
| 1457 |
search. |
| 1458 |
|
| 1459 |
This is a required parameter. |
| 1460 |
|
| 1461 |
Here is an example that creates a new dynamic column that stores the |
| 1462 |
number of characters of content. This example uses |
| 1463 |
:doc:`/reference/functions/string_length` function in |
| 1464 |
``functions/string`` plugin to compute the number of characters in a |
| 1465 |
string. :doc:`plugin_register` is used to register |
| 1466 |
``functions/string`` plugin: |
| 1467 |
|
| 1468 |
.. groonga-command |
| 1469 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_columns_name_value.log |
| 1470 |
.. plugin_register functions/string \ |
| 1471 |
.. logical_select \ |
| 1472 |
.. --logical_table Entries \ |
| 1473 |
.. --shard_key created_at \ |
| 1474 |
.. --limit 0 \ |
| 1475 |
.. --output_columns _id \ |
| 1476 |
.. --drilldowns[tag].keys tag \ |
| 1477 |
.. --drilldowns[tag].columns[tag_length].stage initial \ |
| 1478 |
.. --drilldowns[tag].columns[tag_length].type UInt32 \ |
| 1479 |
.. --drilldowns[tag].columns[tag_length].value 'string_length(_key)' \ |
| 1480 |
.. --drilldowns[tag].output_columns _key,tag_length |
| 1481 |
|
| 1482 |
.. _logical-select-drilldowns-label-columns-name-window-sort-keys: |
| 1483 |
|
| 1484 |
``drilldowns[${LABEL}].columns[${NAME}].window.sort_keys`` |
| 1485 |
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1486 |
|
| 1487 |
.. versionadded:: 7.0.1 |
| 1488 |
|
| 1489 |
Corresponds to :ref:`logical-select-columns-name-window-sort-keys` in |
| 1490 |
main search. |
| 1491 |
|
| 1492 |
You must specify |
| 1493 |
:ref:`logical-select-drilldowns-label-columns-name-window-sort-keys` |
| 1494 |
or |
| 1495 |
:ref:`logical-select-drilldowns-label-columns-name-window-group-keys` |
| 1496 |
to use window function. |
| 1497 |
|
| 1498 |
Here is an example that computes the Nth record in the number of sub |
| 1499 |
records order: |
| 1500 |
|
| 1501 |
.. groonga-command |
| 1502 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_columns_name_window_sort_keys.log |
| 1503 |
.. logical_select \ |
| 1504 |
.. --logical_table Entries \ |
| 1505 |
.. --shard_key created_at \ |
| 1506 |
.. --limit 0 \ |
| 1507 |
.. --output_columns _id \ |
| 1508 |
.. --drilldowns[tag].keys tag \ |
| 1509 |
.. --drilldowns[tag].columns[record_number].stage initial \ |
| 1510 |
.. --drilldowns[tag].columns[record_number].type UInt32 \ |
| 1511 |
.. --drilldowns[tag].columns[record_number].value 'window_record_number()' \ |
| 1512 |
.. --drilldowns[tag].columns[record_number].window.sort_keys _nsubrecs,_key \ |
| 1513 |
.. --drilldowns[tag].sort_keys record_number \ |
| 1514 |
.. --drilldowns[tag].output_columns _key,_nsubrecs,record_number |
| 1515 |
|
| 1516 |
.. _logical-select-drilldowns-label-columns-name-window-group-keys: |
| 1517 |
|
| 1518 |
``drilldowns[${LABEL}].columns[${NAME}].window.group_keys`` |
| 1519 |
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
| 1520 |
|
| 1521 |
.. versionadded:: 7.0.1 |
| 1522 |
|
| 1523 |
Corresponds to :ref:`logical-select-columns-name-window-group-keys` in |
| 1524 |
main search. |
| 1525 |
|
| 1526 |
You must specify |
| 1527 |
:ref:`logical-select-drilldowns-label-columns-name-window-sort-keys` |
| 1528 |
or |
| 1529 |
:ref:`logical-select-drilldowns-label-columns-name-window-group-keys` |
| 1530 |
to use window function. |
| 1531 |
|
| 1532 |
Here is an example that computes the Nth record ordered by tag name |
| 1533 |
for each the same number of sub records: |
| 1534 |
|
| 1535 |
.. groonga-command |
| 1536 |
.. include:: ../../example/reference/commands/logical_select/drilldowns_label_columns_name_window_group_keys.log |
| 1537 |
.. logical_select \ |
| 1538 |
.. --logical_table Entries \ |
| 1539 |
.. --shard_key created_at \ |
| 1540 |
.. --limit 0 \ |
| 1541 |
.. --output_columns _id \ |
| 1542 |
.. --drilldowns[tag].keys tag \ |
| 1543 |
.. --drilldowns[tag].columns[record_number].stage initial \ |
| 1544 |
.. --drilldowns[tag].columns[record_number].type UInt32 \ |
| 1545 |
.. --drilldowns[tag].columns[record_number].value 'window_record_number()' \ |
| 1546 |
.. --drilldowns[tag].columns[record_number].window.sort_keys _key \ |
| 1547 |
.. --drilldowns[tag].columns[record_number].window.group_keys _nsubrecs \ |
| 1548 |
.. --drilldowns[tag].sort_keys _nsubrecs,record_number \ |
| 1549 |
.. --drilldowns[tag].output_columns _key,_nsubrecs,record_number |
| 1550 |
|
| 1551 |
Cache related parameter |
| 1552 |
^^^^^^^^^^^^^^^^^^^^^^^ |
| 1553 |
|
| 1554 |
.. _logical-select-cache: |
| 1555 |
|
| 1556 |
``cache`` |
| 1557 |
""""""""" |
| 1558 |
|
| 1559 |
Specifies whether caching the result of this query or not. |
| 1560 |
|
| 1561 |
If the result of this query is cached, the next same query returns |
| 1562 |
response quickly by using the cache. |
| 1563 |
|
| 1564 |
It doesn't control whether existing cached result is used or not. |
| 1565 |
|
| 1566 |
Here are available values: |
| 1567 |
|
| 1568 |
.. list-table:: |
| 1569 |
:header-rows: 1 |
| 1570 |
|
| 1571 |
* - Value |
| 1572 |
- Description |
| 1573 |
* - ``no`` |
| 1574 |
- Don't cache the output of this query. |
| 1575 |
* - ``yes`` |
| 1576 |
- Cache the output of this query. |
| 1577 |
It's the default value. |
| 1578 |
|
| 1579 |
Here is an example to disable caching the result of this query: |
| 1580 |
|
| 1581 |
.. groonga-command |
| 1582 |
.. include:: ../../example/reference/commands/logical_select/cache_no.log |
| 1583 |
.. logical_select \ |
| 1584 |
.. --logical_table Entries \ |
| 1585 |
.. --shard_key created_at \ |
| 1586 |
.. --cache no |
| 1587 |
|
| 1588 |
The default value is ``yes``. |
| 1589 |
|
| 1590 |
Return value |
| 1591 |
------------ |
| 1592 |
|
| 1593 |
The return value format of ``logical_select`` is compatible with |
| 1594 |
:doc:`select`. See :ref:`select-return-value` for details. |