Skip to main content
`Ctrl`+`K`

# 7.3.38. `logical_select`

## 7.3.38.1. Summary

Added in version 5.0.5.

`logical_select` is a sharding version of select. `logical_select` searches records from multiple tables and outputs them.

You need to plugin_register `sharding` plugin because this command is included in `sharding` plugin.

## 7.3.38.2. Syntax

This command takes many parameters.

The required parameters are `logical_table` and `shard_key`. Other parameters are optional:

    logical_select logical_table
                   shard_key
                   [min=null]
                   [min_border="include"]
                   [max=null]
                   [max_border="include"]
                   [filter=null]
                   [sortby=null]
                   [output_columns="_id, _key, *"]
                   [offset=0]
                   [limit=10]
                   [drilldown=null]
                   [drilldown_sortby=null]
                   [drilldown_output_columns="_key, _nsubrecs"]
                   [drilldown_offset=0]
                   [drilldown_limit=10]
                   [drilldown_calc_types=NONE]
                   [drilldown_calc_target=null]
                   [sort_keys=null]
                   [drilldown_sort_keys=null]
                   [match_columns=null]
                   [query=null]
                   [drilldown_filter=null]
                   [post_filter=null]
                   [load_table=null]
                   [load_columns=null]
                   [load_values=null]

There are some parameters that can be only used as named parameters. You can’t use these parameters as ordered parameters. You must specify parameter name.

Here are parameters that can be only used as named parameters:

> - `cache=no`

This command has the following named parameters for dynamic columns:

> - `columns[${NAME}].stage=null`

> - `columns[${NAME}].flags=COLUMN_SCALAR`

> - `columns[${NAME}].type=null`

> - `columns[${NAME}].value=null`

> - `columns[${NAME}].window.sort_keys=null`

> - `columns[${NAME}].window.group_keys=null`

You can use one or more alphabets, digits, `_` for `${NAME}`. For example, `column1` is a valid `${NAME}`. This is the same rule as normal column. See also name.

Parameters that have the same `${NAME}` are grouped.

For example, the following parameters specify one dynamic column:

> - `--columns[name].stage initial`

> - `--columns[name].type UInt32`

> - `--columns[name].value 29`

The following parameters specify two dynamic columns:

> - `--columns[name1].stage initial`

> - `--columns[name1].type UInt32`

> - `--columns[name1].value 29`

> - `--columns[name2].stage filtered`

> - `--columns[name2].type Float`

> - `--columns[name2].value '_score * 0.1'`

This command has the following named parameters for advanced drilldown:

> - `drilldowns[${LABEL}].keys=null`

> - `drilldowns[${LABEL}].sort_keys=null`

> - `drilldowns[${LABEL}].output_columns="_key, _nsubrecs"`

> - `drilldowns[${LABEL}].offset=0`

> - `drilldowns[${LABEL}].limit=10`

> - `drilldowns[${LABEL}].calc_types=NONE`

> - `drilldowns[${LABEL}].calc_target=null`

> - `drilldowns[${LABEL}].filter=null`

> - `drilldowns[${LABEL}].columns[${NAME}].stage=null`

> - `drilldowns[${LABEL}].columns[${NAME}].flags=COLUMN_SCALAR`

> - `drilldowns[${LABEL}].columns[${NAME}].type=null`

> - `drilldowns[${LABEL}].columns[${NAME}].value=null`

> - `drilldowns[${LABEL}].columns[${NAME}].window.sort_keys=null`

> - `drilldowns[${LABEL}].columns[${NAME}].window.group_keys=null`

Deprecated since version 6.1.4: `drilldown[...]` syntax is deprecated. Use `drilldowns[...]` instead.

Deprecated since version 6.1.5: drilldowns[${LABEL}].sortby is deprecated. Use drilldowns[${LABEL}].sort_keys instead.

You can use one or more alphabets, digits, `_` and `.` for `${LABEL}`. For example, `parent.sub1` is a valid `${LABEL}`.

Parameters that have the same `${LABEL}` are grouped.

For example, the following parameters specify one drilldown:

> - `--drilldowns[label].keys column`

> - `--drilldowns[label].sort_keys -_nsubrecs`

The following parameters specify two drilldowns:

> - `--drilldowns[label1].keys column1`

> - `--drilldowns[label1].sort_keys -_nsubrecs`

> - `--drilldowns[label2].keys column2`

> - `--drilldowns[label2].sort_keys _key`

## 7.3.38.3. Differences from `select`

Most of `logical_select` features can be used like corresponding select features. For example, parameter name is same, output format is same and so on.

But there are some differences from select:

> - `logical_table` and `shard_key` parameters are required instead of `table` parameter.

> - `sort_keys` isn’t supported when multiple shards are used. (Only one shard is used, they are supported. There is one exception about `sort_keys` for multiple shards. When `shard_keys` and `sort_keys` are same, they are supported. See sort_keys about details)

> - `_value.${KEY_NAME}` in `drilldowns[${LABEL}].sort_keys` doesn’t work with multiple shards. It works with one shard. `_key` in `drilldowns[${LABEL}].sort_keys` work with multiple shards.

> - `_value.${KEY_NAME}` in `drilldowns[${LABEL}].output_columns` also doesn’t work with multiple shards either. It works with one shard.

> - `match_escalation_threshold` isn’t supported yet.

> - `query_flags` isn’t supported yet.

> - `query_expander` isn’t supported yet.

> - `adjuster` isn’t supported yet.

## 7.3.38.4. Usage

Let’s learn about usage with examples. This section shows many popular usages.

You need to register `sharding` plugin because this command is included in `sharding` plugin.

Execution example:

    plugin_register sharding
    # [[0,1337566253.89858,0.000355720520019531],true]

Here are a schema definition and sample data to show usage.

Execution example:

    table_create Entries_20150708 TABLE_HASH_KEY ShortText
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150708 created_at COLUMN_SCALAR Time
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150708 content COLUMN_SCALAR Text
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150708 n_likes COLUMN_SCALAR UInt32
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150708 tag COLUMN_SCALAR ShortText
    # [[0,1337566253.89858,0.000355720520019531],true]
    table_create Entries_20150709 TABLE_HASH_KEY ShortText
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150709 created_at COLUMN_SCALAR Time
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150709 content COLUMN_SCALAR Text
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150709 n_likes COLUMN_SCALAR UInt32
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Entries_20150709 tag COLUMN_SCALAR ShortText
    # [[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 entries_key_index_20150708 \
      COLUMN_INDEX|WITH_POSITION Entries_20150708 _key
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Terms entries_content_index_20150708 \
      COLUMN_INDEX|WITH_POSITION Entries_20150708 content
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Terms entries_key_index_20150709 \
      COLUMN_INDEX|WITH_POSITION Entries_20150709 _key
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Terms entries_content_index_20150709 \
      COLUMN_INDEX|WITH_POSITION Entries_20150709 content
    # [[0,1337566253.89858,0.000355720520019531],true]
    load --table Entries_20150708
    [
    {"_key":       "The first post!",
     "created_at": "2015/07/08 00:00:00",
     "content":    "Welcome! This is my first post!",
     "n_likes":    5,
     "tag":        "Hello"},
    {"_key":       "Groonga",
     "created_at": "2015/07/08 01:00:00",
     "content":    "I started to use Groonga. It's very fast!",
     "n_likes":    10,
     "tag":        "Groonga"},
    {"_key":       "Mroonga",
     "created_at": "2015/07/08 02:00:00",
     "content":    "I also started to use Mroonga. It's also very fast! Really fast!",
     "n_likes":    15,
     "tag":        "Groonga"}
    ]
    # [[0,1337566253.89858,0.000355720520019531],3]
    load --table Entries_20150709
    [
    {"_key":       "Good-bye Senna",
     "created_at": "2015/07/09 00:00:00",
     "content":    "I migrated all Senna system!",
     "n_likes":    3,
     "tag":        "Senna"},
    {"_key":       "Good-bye Tritonn",
     "created_at": "2015/07/09 01:00:00",
     "content":    "I also migrated all Tritonn system!",
     "n_likes":    3,
     "tag":        "Senna"}
    ]
    # [[0,1337566253.89858,0.000355720520019531],2]

There are two tables, `Entries_20150708` and `Entries_20150709`, for blog entries.

Note

You need to use `${LOGICAL_TABLE_NAME}_${YYYYMMDD}` naming rule for table names. In this example, `LOGICAL_TABLE_NAME` is `Entries` and `YYYYMMDD` is `20150708` or `20150709`.

An entry has title, created time, content, the number of likes for the entry and tag. Title is key of `Entries_YYYYMMDD`. Created time is value of `Entries_YYYYMMDD.created_at` column. Content is value of `Entries_YYYYMMDD.content` column. The number of likes is value of `Entries_YYYYMMDD.n_likes` column. Tag is value of `Entries_YYYYMMDD.tag` column.

`Entries_YYYYMMDD._key` column and `Entries_YYYYMMDD.content` column are indexed using `TokenBigram` tokenizer. So both `Entries_YYYYMMDD._key` and `Entries_YYYYMMDD.content` are fulltext search ready.

OK. The schema and data for examples are ready.

### 7.3.38.4.1. Simple usage

Here is an example that specifies only required parameters.

Execution example:

    logical_select --logical_table Entries --shard_key created_at
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ],
    #       [
    #         1,
    #         "Good-bye Senna",
    #         "I migrated all Senna system!",
    #         1436367600.0,
    #         3,
    #         "Senna"
    #       ],
    #       [
    #         2,
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

It is shown that is searched from Entries_20150708 and Entries_20150709 in above example.

## 7.3.38.5. Parameters

This section describes parameters of `logical_select`.

### 7.3.38.5.1. Required parameters

There are required parameters, `logical_table` and `shard_key`.

#### 7.3.38.5.1.1. `logical_table`

Specifies logical table name. It means table name without `_YYYYMMDD` postfix. If you use actual table such as `Entries_20150708`, `Entries_20150709` and so on, logical table name is `Entries`.

You can show 5 records by specifying `logical_table` and `shard_key` parameters. They are required parameters.

Execution example:

    logical_select --logical_table Entries --shard_key created_at
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ],
    #       [
    #         1,
    #         "Good-bye Senna",
    #         "I migrated all Senna system!",
    #         1436367600.0,
    #         3,
    #         "Senna"
    #       ],
    #       [
    #         2,
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

If nonexistent table is specified, an error is returned.

Execution example:

    logical_select --logical_table Nonexistent --shard_key created_at
    # [
    #   [
    #     -22,
    #     1337566253.89858,
    #     0.000355720520019531,
    #     "[logical_select] no shard exists: logical_table: <Nonexistent>: shard_key: <created_at>",
    #     [
    #       [
    #         "execute_search",
    #         "lib/groonga/plugins/sharding/logical_select.rb",
    #         2929
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.1.2. `shard_key`

Specifies column name which is treated as shared key. Shard key is a column that stores data that is used for distributing records to suitable shards.

Shard key must be `Time` type for now.

See logical_table how to specify `shard_key`.

### 7.3.38.5.2. Optional parameters

There are optional parameters.

#### 7.3.38.5.2.1. `min`

Specifies the minimum value of `shard_key` column. If shard doesn’t have any matched records, the shard isn’t searched.

For example, `min` is `"2015/07/09 00:00:00"`, `Entry_20150708` isn’t searched. Because `Entry_20150708` has only records for `"2015/07/08"`.

The following example only uses `Entry_20150709` table. `Entry_20150708` isn’t used.

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --min "2015/07/09 00:00:00"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         2
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "Good-bye Senna",
    #         "I migrated all Senna system!",
    #         1436367600.0,
    #         3,
    #         "Senna"
    #       ],
    #       [
    #         2,
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.2.2. `min_border`

Specifies whether the minimum value is included or not. Here is available values.

Value | Description
--- | ---
`include` | Includes `min` value. This is the default.
`exclude` | Doesn’t include `min` value.

Here is an example for `exclude`. The result doesn’t include the `"Good-bye Senna"` record because its `created_at` value is `"2015/07/09 00:00:00"`.

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --min "2015/07/09 00:00:00" \
      --min_border "exclude"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         1
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         2,
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.2.3. `max`

Specifies the maximum value of `shard_key` column. If shard doesn’t have any matched records, the shard isn’t searched.

For example, `max` is `"2015/07/08 23:59:59"`, `Entry_20150709` isn’t searched. Because `Entry_20150709` has only records for `""2015/07/09"`.

The following example only uses `Entry_20150708` table. `Entry_20150709` isn’t used.

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --max "2015/07/08 23:59:59"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.2.4. `max_border`

Specifies whether the maximum value is included or not. Here is available values.

Value | Description
--- | ---
`include` | Includes `max` value. This is the default.
`exclude` | Doesn’t include `max` value.

Here is an example for `exclude`. The result doesn’t include the `"Good-bye Senna"` record because its `created_at` value is `"2015/07/09 00:00:00"`.

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --max "2015/07/09 00:00:00" \
      --max_border "exclude"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ]
    #     ]
    #   ]
    # ]

### 7.3.38.5.3. Search related parameters

This command provides select compatible search related parameters.

#### 7.3.38.5.3.1. `match_columns`

Added in version 7.0.1.

Corresponds to match_columns in select. See match_columns for details.

Here is an example to find records that include `"fast"` text in `content` column:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --match_columns content \
      --query "fast"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         2
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.3.2. `query`

Added in version 7.0.1.

Corresponds to query in select. See query for details.

Here is an example to find records that include `"fast"` text in `content` column:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --query "content:@fast"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         2
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ]
    #     ]
    #   ]
    # ]

See also match_columns.

#### 7.3.38.5.3.3. `filter`

Corresponds to filter in select. See filter for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --filter "n_likes <= 5"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         1,
    #         "Good-bye Senna",
    #         "I migrated all Senna system!",
    #         1436367600.0,
    #         3,
    #         "Senna"
    #       ],
    #       [
    #         2,
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.3.4. `post_filter`

Added in version 8.0.1.

Specifies the filter text that is processed after `filtered` stage dynamic columns are generated. You can use `post_filter` to filter by `filtered` stage dynamic columns. Others are the same as filter.

Here is an example that shows entries only in popular tag. All target entries have `system` or `use` words:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --columns[n_likes_sum_per_tag].stage filtered \
      --columns[n_likes_sum_per_tag].type UInt32 \
      --columns[n_likes_sum_per_tag].value 'window_sum(n_likes)' \
      --columns[n_likes_sum_per_tag].window.group_keys 'tag' \
      --filter 'content @ "system" || content @ "use"' \
      --post_filter 'n_likes_sum_per_tag > 10' \
      --output_columns _key,n_likes,n_likes_sum_per_tag
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         2
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "n_likes_sum_per_tag",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         "Groonga",
    #         10,
    #         25
    #       ],
    #       [
    #         "Mroonga",
    #         15,
    #         25
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.3.5. `load_table`

Added in version 8.1.1.

You can store specified a table a result of `logical_select` with `--load_table`, `--load-columns` and `--load_values` arguments. `--load_table` specifies a table name for storing a result of `logical_select`.

You must specify a table that already exists.

This argument must use with load_columns and load_values.

Here is an example that can store `_id` and `timestamp` that a result of `logical_select` in a Logs table specified by `--load_table`.

Execution example:

    table_create Logs_20150203 TABLE_HASH_KEY ShortText
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Logs_20150203 timestamp COLUMN_SCALAR Time
    # [[0,1337566253.89858,0.000355720520019531],true]
    table_create Logs_20150204 TABLE_HASH_KEY ShortText
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Logs_20150204 timestamp COLUMN_SCALAR Time
    # [[0,1337566253.89858,0.000355720520019531],true]
    table_create Logs TABLE_HASH_KEY ShortText
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Logs original_id COLUMN_SCALAR UInt32
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create Logs timestamp_text COLUMN_SCALAR ShortText
    # [[0,1337566253.89858,0.000355720520019531],true]
    load --table Logs_20150203
    [
    {
      "_key": "2015-02-03:1",
      "timestamp": "2015-02-03 10:49:00"
    },
    {
      "_key": "2015-02-03:2",
      "timestamp": "2015-02-03 12:49:00"
    }
    ]
    # [[0,1337566253.89858,0.000355720520019531],2]
    load --table Logs_20150204
    [
    {
      "_key": "2015-02-04:1",
      "timestamp": "2015-02-04 00:00:00"
    }
    ]
    # [[0,1337566253.89858,0.000355720520019531],1]
    logical_select \
      --logical_table Logs \
      --shard_key timestamp \
      --load_table Logs \
      --load_columns "_key, original_id, timestamp_text" \
      --load_values "_key, _id, timestamp"
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "timestamp",
    #           "Time"
    #         ]
    #       ],
    #       [
    #         1,
    #         "2015-02-03:1",
    #         1422928140.0
    #       ],
    #       [
    #         2,
    #         "2015-02-03:2",
    #         1422935340.0
    #       ],
    #       [
    #         1,
    #         "2015-02-04:1",
    #         1422975600.0
    #       ]
    #     ]
    #   ]
    # ]
    select --table Logs
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "original_id",
    #           "UInt32"
    #         ],
    #         [
    #           "timestamp_text",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "2015-02-03:1",
    #         1,
    #         "1422928140000000"
    #       ],
    #       [
    #         2,
    #         "2015-02-03:2",
    #         2,
    #         "1422935340000000"
    #       ],
    #       [
    #         3,
    #         "2015-02-04:1",
    #         1,
    #         "1422975600000000"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.3.6. `load_columns`

Added in version 8.1.1.

Specifies columns of a table that specifying `--load-table`. Stores value of columns that specified with load_values in columns that specified with this argument. You must specify columns that already exists.

This argument must use with load_table and load_values.

See example of `--load_table` for how to use this argument.

#### 7.3.38.5.3.7. `load_values`

Added in version 8.1.1.

Specifies columns of result of `logical_select`. Specifies columns for storing values into columns that specified with load_columns. You must specify columns that already exists.

This argument must use with load_table and load_columns.

See example of `--load_table` for how to use this argument.

### 7.3.38.5.4. Advanced search parameters

`logical_select` doesn’t implement advanced search parameters yet.

#### 7.3.38.5.4.1. `match_escalation_threshold`

Not implemented yet.

#### 7.3.38.5.4.2. `query_flags`

Not implemented yet.

#### 7.3.38.5.4.3. `query_expander`

Not implemented yet.

### 7.3.38.5.5. Output related parameters

#### 7.3.38.5.5.1. `output_columns`

Corresponds to output_columns in select. See output_columns for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --output_columns '_key, *'
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ],
    #       [
    #         "Good-bye Senna",
    #         "I migrated all Senna system!",
    #         1436367600.0,
    #         3,
    #         "Senna"
    #       ],
    #       [
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.5.2. `sortby`

Deprecated since version 6.1.5: Use sort_keys instead.

#### 7.3.38.5.5.3. `sort_keys`

Corresponds to sort_keys in select. See sort_keys for details.

`sort_keys` has a limitation. It works only when the number of search target shards is one. If the number of search target shards is larger than one, `sort_keys` doesn’t work.

Note

There is one exception for multiple shards. When the same value is specified for `shard_key` and `sort_keys`, they are supported. This command processes target shards one by one by ascending order. Thus, in this process, magnitude correlation about the value of `shard_key` is kept among them. This is because `sort_keys` is supported when `shard_key` and `sort_keys` is same.

Here is an example that uses only one shard:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --min "2015/07/08 00:00:00" \
      --min_border "include" \
      --max "2015/07/09 00:00:00" \
      --max_border "exclude" \
      --sort_keys _key
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.5.4. `offset`

Corresponds to offset in select. See offset for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --offset 2
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ],
    #       [
    #         1,
    #         "Good-bye Senna",
    #         "I migrated all Senna system!",
    #         1436367600.0,
    #         3,
    #         "Senna"
    #       ],
    #       [
    #         2,
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.5.5. `limit`

Corresponds to limit in select. See limit for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 2
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.5.6. `scorer`

Not implemented yet.

### 7.3.38.5.6. Dynamic column related parameters

Added in version 7.0.1.

All dynamic column related parameters in select are supported. See Dynamic column related parameters for details.

#### 7.3.38.5.6.1. `columns[${NAME}].stage`

Added in version 7.0.1.

Corresponds to columns[${NAME}].stage in select. See columns[${NAME}].stage for details.

This is a required parameter.

Here is an example that creates `is_popular` column at `initial` stage. You can use `is_popular` in all parameters such as `filter` and `output_columns`:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --columns[is_popular].stage initial \
      --columns[is_popular].type Bool \
      --columns[is_popular].value 'n_likes >= 10' \
      --filter is_popular \
      --output_columns _id,is_popular,n_likes
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         2
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "is_popular",
    #           "Bool"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         2,
    #         true,
    #         10
    #       ],
    #       [
    #         3,
    #         true,
    #         15
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.6.2. `columns[${NAME}].flags`

Added in version 7.0.1.

Corresponds to columns[${NAME}].flags in select. See columns[${NAME}].flags for details.

The default value is `COLUMN_SCALAR`.

Here is an example that creates a vector column by `COLUMN_VECTOR` flags. `plugin_register functions/vector` is for using vector_new function:

Execution example:

    plugin_register functions/vector
    # [[0,1337566253.89858,0.000355720520019531],true]
    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --columns[vector].stage initial \
      --columns[vector].flags COLUMN_VECTOR \
      --columns[vector].type UInt32 \
      --columns[vector].value 'vector_new(1, 2, 3)' \
      --output_columns _id,vector
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "vector",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         1,
    #         [
    #           1,
    #           2,
    #           3
    #         ]
    #       ],
    #       [
    #         2,
    #         [
    #           1,
    #           2,
    #           3
    #         ]
    #       ],
    #       [
    #         3,
    #         [
    #           1,
    #           2,
    #           3
    #         ]
    #       ],
    #       [
    #         1,
    #         [
    #           1,
    #           2,
    #           3
    #         ]
    #       ],
    #       [
    #         2,
    #         [
    #           1,
    #           2,
    #           3
    #         ]
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.6.3. `columns[${NAME}].type`

Added in version 7.0.1.

Corresponds to columns[${NAME}].type in select. See columns[${NAME}].type for details.

This is a required parameter.

Here is an example that creates a `ShortText` type column. Stored value is casted to `ShortText` automatically. In this example, number is casted to `ShortText`:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --columns[n_likes_string].stage initial \
      --columns[n_likes_string].type ShortText \
      --columns[n_likes_string].value n_likes \
      --output_columns _id,n_likes,n_likes_string
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "n_likes_string",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         5,
    #         "5"
    #       ],
    #       [
    #         2,
    #         10,
    #         "10"
    #       ],
    #       [
    #         3,
    #         15,
    #         "15"
    #       ],
    #       [
    #         1,
    #         3,
    #         "3"
    #       ],
    #       [
    #         2,
    #         3,
    #         "3"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.6.4. `columns[${NAME}].value`

Added in version 7.0.1.

Corresponds to columns[${NAME}].value in select. See columns[${NAME}].value for details.

You need to specify Window function as `value` value and other window function related parameters when you use window function. See Window function related parameters for details.

This is a required parameter.

Here is an example that creates a new dynamic column that stores the number of characters of content. This example uses string_length function in `functions/string` plugin to compute the number of characters in a string. plugin_register is used to register `functions/string` plugin:

Execution example:

    plugin_register functions/string
    # [[0,1337566253.89858,0.000355720520019531],true]
    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --columns[content_length].stage initial \
      --columns[content_length].type UInt32 \
      --columns[content_length].value 'string_length(content)' \
      --output_columns _id,content,content_length
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "content_length",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         1,
    #         "Welcome! This is my first post!",
    #         31
    #       ],
    #       [
    #         2,
    #         "I started to use Groonga. It's very fast!",
    #         41
    #       ],
    #       [
    #         3,
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         64
    #       ],
    #       [
    #         1,
    #         "I migrated all Senna system!",
    #         28
    #       ],
    #       [
    #         2,
    #         "I also migrated all Tritonn system!",
    #         35
    #       ]
    #     ]
    #   ]
    # ]

### 7.3.38.5.7. Window function related parameters

Added in version 7.0.1.

All window function related parameters in select are supported. See Window function related parameters for details.

Note

Window function over multiple tables aren’t supported version 9.0.1 or before. Groonga supported it since version 9.0.2 or later. However, we need to align the same order for shard key and leading group key or sort key.

For example, we can apply the window function to over multiple tables as below case. Because the below example aligns the same order for shard key and leading group key.

The leading group key is `price` and shard key is `timestamp` in the below example. We can apply the window function to over multiple tables in the below example. Because `price` and `timestamp` aligns the same order.

Execution example:

    plugin_register sharding
    # [[0,1337566253.89858,0.000355720520019531],true]
    table_create ItemLogs_20170415 TABLE_NO_KEY
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create ItemLogs_20170415 timestamp COLUMN_SCALAR Time
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create ItemLogs_20170415 price COLUMN_SCALAR UInt32
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create ItemLogs_20170415 n_likes COLUMN_SCALAR UInt32
    # [[0,1337566253.89858,0.000355720520019531],true]
    table_create ItemLogs_20170416 TABLE_NO_KEY
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create ItemLogs_20170416 timestamp COLUMN_SCALAR Time
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create ItemLogs_20170416 price COLUMN_SCALAR UInt32
    # [[0,1337566253.89858,0.000355720520019531],true]
    column_create ItemLogs_20170416 n_likes COLUMN_SCALAR UInt32
    # [[0,1337566253.89858,0.000355720520019531],true]
    load --table ItemLogs_20170415
    [
    {"timestamp": "2017/04/15 00:00:00", "n_likes": 2, "price": 100},
    {"timestamp": "2017/04/15 01:00:00", "n_likes": 1, "price": 100},
    {"timestamp": "2017/04/15 01:00:00", "n_likes": 2, "price": 200}
    ]
    # [[0,1337566253.89858,0.000355720520019531],3]
    load --table ItemLogs_20170416
    [
    {"timestamp": "2017/04/16 10:00:00", "n_likes": 1, "price": 200},
    {"timestamp": "2017/04/16 11:00:00", "n_likes": 2, "price": 300},
    {"timestamp": "2017/04/16 11:00:00", "n_likes": 1, "price": 300}
    ]
    # [[0,1337566253.89858,0.000355720520019531],3]
    logical_select ItemLogs \
      --shard_key timestamp \
      --columns[count].stage initial \
      --columns[count].type UInt32 \
      --columns[count].flags COLUMN_SCALAR \
      --columns[count].value 'window_count()' \
      --columns[count].window.group_keys price \
      --output_columns price,count
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         6
    #       ],
    #       [
    #         [
    #           "price",
    #           "UInt32"
    #         ],
    #         [
    #           "count",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         100,
    #         2
    #       ],
    #       [
    #         100,
    #         2
    #       ],
    #       [
    #         200,
    #         2
    #       ],
    #       [
    #         200,
    #         2
    #       ],
    #       [
    #         300,
    #         2
    #       ],
    #       [
    #         300,
    #         2
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.7.1. `columns[${NAME}].window.sort_keys`

Added in version 7.0.1.

Corresponds to columns[${NAME}].window.sort_keys in select. See columns[${NAME}].window.sort_keys for details.

You must specify columns[${NAME}].window.sort_keys or columns[${NAME}].window.group_keys to use window function.

Here is an example that computes cumulative sum per `Entries.tag`. Each group is sorted by `Entries._key`:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --columns[n_likes_cumulative_sum_per_tag].stage initial \
      --columns[n_likes_cumulative_sum_per_tag].type UInt32 \
      --columns[n_likes_cumulative_sum_per_tag].value 'window_sum(n_likes)' \
      --columns[n_likes_cumulative_sum_per_tag].window.sort_keys _key \
      --columns[n_likes_cumulative_sum_per_tag].window.group_keys tag \
      --sort_keys _key \
      --output_columns tag,_key,n_likes,n_likes_cumulative_sum_per_tag
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "tag",
    #           "ShortText"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "n_likes_cumulative_sum_per_tag",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         "Groonga",
    #         "Groonga",
    #         10,
    #         10
    #       ],
    #       [
    #         "Groonga",
    #         "Mroonga",
    #         15,
    #         25
    #       ],
    #       [
    #         "Hello",
    #         "The first post!",
    #         5,
    #         5
    #       ],
    #       [
    #         "Senna",
    #         "Good-bye Senna",
    #         3,
    #         3
    #       ],
    #       [
    #         "Senna",
    #         "Good-bye Tritonn",
    #         3,
    #         6
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.7.2. `columns[${NAME}].window.group_keys`

Added in version 7.0.1.

Corresponds to columns[${NAME}].window.group_keys in select. See columns[${NAME}].window.group_keys for details.

You must specify columns[${NAME}].window.sort_keys or columns[${NAME}].window.group_keys to use window function.

Here is an example that computes sum per `Entries.tag`:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --columns[n_likes_sum_per_tag].stage initial \
      --columns[n_likes_sum_per_tag].type UInt32 \
      --columns[n_likes_sum_per_tag].value 'window_sum(n_likes)' \
      --columns[n_likes_sum_per_tag].window.group_keys tag \
      --sort_keys _key \
      --output_columns tag,_key,n_likes,n_likes_sum_per_tag
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "tag",
    #           "ShortText"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "n_likes_sum_per_tag",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         "Groonga",
    #         "Groonga",
    #         10,
    #         25
    #       ],
    #       [
    #         "Groonga",
    #         "Mroonga",
    #         15,
    #         25
    #       ],
    #       [
    #         "Hello",
    #         "The first post!",
    #         5,
    #         5
    #       ],
    #       [
    #         "Senna",
    #         "Good-bye Senna",
    #         3,
    #         6
    #       ],
    #       [
    #         "Senna",
    #         "Good-bye Tritonn",
    #         3,
    #         6
    #       ]
    #     ]
    #   ]
    # ]

### 7.3.38.5.8. Drilldown related parameters

All drilldown related parameters in select are supported. See Drilldown related parameters for details.

#### 7.3.38.5.8.1. `drilldown`

Corresponds to drilldown in select. See drilldown for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --output_columns _key,tag \
      --drilldown tag
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         "The first post!",
    #         "Hello"
    #       ],
    #       [
    #         "Groonga",
    #         "Groonga"
    #       ],
    #       [
    #         "Mroonga",
    #         "Groonga"
    #       ],
    #       [
    #         "Good-bye Senna",
    #         "Senna"
    #       ],
    #       [
    #         "Good-bye Tritonn",
    #         "Senna"
    #       ]
    #     ],
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "_nsubrecs",
    #           "Int32"
    #         ]
    #       ],
    #       [
    #         "Hello",
    #         1
    #       ],
    #       [
    #         "Groonga",
    #         2
    #       ],
    #       [
    #         "Senna",
    #         2
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.8.2. `drilldown_sortby`

Deprecated since version 6.1.5: Use drilldown_sort_keys instead.

#### 7.3.38.5.8.3. `drilldown_sort_keys`

Corresponds to drilldown_sort_keys in select. See drilldown_sort_keys for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldown tag \
      --drilldown_sort_keys -_nsubrecs,_key
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "_nsubrecs",
    #           "Int32"
    #         ]
    #       ],
    #       [
    #         "Groonga",
    #         2
    #       ],
    #       [
    #         "Senna",
    #         2
    #       ],
    #       [
    #         "Hello",
    #         1
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.8.4. `drilldown_output_columns`

Corresponds to drilldown_output_columns in select. See drilldown_output_columns for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldown tag \
      --drilldown_output_columns _key
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         "Hello"
    #       ],
    #       [
    #         "Groonga"
    #       ],
    #       [
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.8.5. `drilldown_offset`

Corresponds to drilldown_offset in select. See drilldown_offset for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldown tag \
      --drilldown_offset 1
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "_nsubrecs",
    #           "Int32"
    #         ]
    #       ],
    #       [
    #         "Groonga",
    #         2
    #       ],
    #       [
    #         "Senna",
    #         2
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.8.6. `drilldown_limit`

Corresponds to drilldown_limit in select. See drilldown_limit for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldown tag \
      --drilldown_limit 2
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "_nsubrecs",
    #           "Int32"
    #         ]
    #       ],
    #       [
    #         "Hello",
    #         1
    #       ],
    #       [
    #         "Groonga",
    #         2
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.8.7. `drilldown_calc_types`

Corresponds to drilldown_calc_types in select. See drilldown_calc_types for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit -1 \
      --output_columns tag,n_likes \
      --drilldown tag \
      --drilldown_calc_types MAX,MIN,SUM,AVG \
      --drilldown_calc_target n_likes \
      --drilldown_output_columns _key,_nsubrecs,_max,_min,_sum,_avg
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "tag",
    #           "ShortText"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ]
    #       ],
    #       [
    #         "Hello",
    #         5
    #       ],
    #       [
    #         "Groonga",
    #         10
    #       ],
    #       [
    #         "Groonga",
    #         15
    #       ],
    #       [
    #         "Senna",
    #         3
    #       ],
    #       [
    #         "Senna",
    #         3
    #       ]
    #     ],
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "_nsubrecs",
    #           "Int32"
    #         ],
    #         [
    #           "_max",
    #           "Int64"
    #         ],
    #         [
    #           "_min",
    #           "Int64"
    #         ],
    #         [
    #           "_sum",
    #           "Int64"
    #         ],
    #         [
    #           "_avg",
    #           "Float"
    #         ]
    #       ],
    #       [
    #         "Hello",
    #         1,
    #         5,
    #         5,
    #         5,
    #         5.0
    #       ],
    #       [
    #         "Groonga",
    #         2,
    #         15,
    #         10,
    #         25,
    #         12.5
    #       ],
    #       [
    #         "Senna",
    #         2,
    #         3,
    #         3,
    #         6,
    #         3.0
    #       ]
    #     ]
    #   ]
    # ]

#### 7.3.38.5.8.8. `drilldown_calc_target`

Corresponds to drilldown_calc_target in select. See drilldown_calc_target for details.

See also drilldown_calc_types for an example.

#### 7.3.38.5.8.9. `drilldown_filter`

Added in version 7.0.1.

Corresponds to drilldown_filter in select. See drilldown_filter for details.

Here is an example to suppress drilled down tags that are occurred only once:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldown tag \
      --drilldown_filter "_nsubrecs > 1" \
      --drilldown_output_columns _key,_nsubrecs
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     [
    #       [
    #         2
    #       ],
    #       [
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "_nsubrecs",
    #           "Int32"
    #         ]
    #       ],
    #       [
    #         "Groonga",
    #         2
    #       ],
    #       [
    #         "Senna",
    #         2
    #       ]
    #     ]
    #   ]
    # ]

### 7.3.38.5.9. Advanced drilldown related parameters

All advanced drilldown related parameters in select are supported. See Advanced drilldown related parameters for details.

There are some limitations:

> - `_value.${KEY_NAME}` in `drilldowns[${LABEL}].sort_keys` doesn’t work with multiple shards. It works with one shard. `_key` in `drilldowns[${LABEL}].sort_key` work with multiple shards.

#### 7.3.38.5.9.1. `drilldowns[${LABEL}].keys`

Corresponds to drilldowns[${LABEL}].keys in select. See drilldowns[${LABEL}].keys for details.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag.n_likes].keys tag,n_likes \
      --drilldowns[tag.n_likes].output_columns _value.tag,_value.n_likes,_nsubrecs
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag.n_likes": [
    #         [
    #           4
    #         ],
    #         [
    #           [
    #             "tag",
    #             "ShortText"
    #           ],
    #           [
    #             "n_likes",
    #             "UInt32"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           5,
    #           1
    #         ],
    #         [
    #           "Groonga",
    #           10,
    #           1
    #         ],
    #         [
    #           "Groonga",
    #           15,
    #           1
    #         ],
    #         [
    #           "Senna",
    #           3,
    #           2
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.2. `drilldowns[${LABEL}].output_columns`

Corresponds to drilldowns[${LABEL}].output_columns in select. See drilldowns[${LABEL}].output_columns for details.

`drilldowns[${LABEL}].output_columns` has a limitation.

`_value.${KEY_NAME}` in `drilldowns[${LABEL}].output_columns` doesn’t work with multiple shards. It works with one shard.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].output_columns _key,_nsubrecs
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           1
    #         ],
    #         [
    #           "Groonga",
    #           2
    #         ],
    #         [
    #           "Senna",
    #           2
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.3. `drilldowns[${LABEL}].sortby`

Deprecated since version 6.1.5: Use drilldowns[${LABEL}].sort_keys instead.

#### 7.3.38.5.9.4. `drilldowns[${LABEL}].sort_keys`

Corresponds to drilldown_sort_keys in not labeled drilldown.

`drilldowns[${LABEL}].sort_keys` has a limitation.

`_value.${KEY_NAME}` in `drilldowns[${LABEL}].sort_keys` doesn’t work with multiple shards. It works with one shard. `_key` in `drilldowns[${LABEL}].sort_keys` work with multiple shards.

Here is an example that uses `_value.${KEY_NAME}` with only one shard:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --min "2015/07/08 00:00:00" \
      --min_border "include" \
      --max "2015/07/09 00:00:00" \
      --max_border "exclude" \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag.n_likes].keys tag,n_likes \
      --drilldowns[tag.n_likes].output_columns _nsubrecs,_value.n_likes,_value.tag \
      --drilldowns[tag.n_likes].sort_keys -_nsubrecs,_value.n_likes,_value.tag
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         3
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag.n_likes": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ],
    #           [
    #             "n_likes",
    #             "UInt32"
    #           ],
    #           [
    #             "tag",
    #             "ShortText"
    #           ]
    #         ],
    #         [
    #           1,
    #           5,
    #           "Hello"
    #         ],
    #         [
    #           1,
    #           10,
    #           "Groonga"
    #         ],
    #         [
    #           1,
    #           15,
    #           "Groonga"
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.5. `drilldowns[${LABEL}].offset`

Corresponds to drilldown_offset in not labeled drilldown.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag.n_likes].keys tag \
      --drilldowns[tag.n_likes].offset 1
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag.n_likes": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ]
    #         ],
    #         [
    #           "Groonga",
    #           2
    #         ],
    #         [
    #           "Senna",
    #           2
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.6. `drilldowns[${LABEL}].limit`

Corresponds to drilldown_limit in not labeled drilldown.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag.n_likes].keys tag \
      --drilldowns[tag.n_likes].limit 2
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag.n_likes": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           1
    #         ],
    #         [
    #           "Groonga",
    #           2
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.7. `drilldowns[${LABEL}].calc_types`

Corresponds to drilldown_calc_types in not labeled drilldown.

Here is an example:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].calc_types MAX,MIN,SUM,AVG \
      --drilldowns[tag].calc_target n_likes \
      --drilldowns[tag].output_columns _key,_nsubrecs,_max,_min,_sum,_avg
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ],
    #           [
    #             "_max",
    #             "Int64"
    #           ],
    #           [
    #             "_min",
    #             "Int64"
    #           ],
    #           [
    #             "_sum",
    #             "Int64"
    #           ],
    #           [
    #             "_avg",
    #             "Float"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           1,
    #           5,
    #           5,
    #           5,
    #           5.0
    #         ],
    #         [
    #           "Groonga",
    #           2,
    #           15,
    #           10,
    #           25,
    #           12.5
    #         ],
    #         [
    #           "Senna",
    #           2,
    #           3,
    #           3,
    #           6,
    #           3.0
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.8. `drilldowns[${LABEL}].calc_target`

Corresponds to drilldown_calc_target in not labeled drilldown.

See also drilldowns[${LABEL}].calc_types for an example.

#### 7.3.38.5.9.9. `drilldowns[${LABEL}].filter`

Added in version 7.0.1.

Corresponds to drilldown_filter in not labeled drilldown.

Here is an example to suppress drilled down tags that are occurred only once:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].filter "_nsubrecs > 1" \
      --drilldowns[tag].output_columns _key,_nsubrecs
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           2
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ]
    #         ],
    #         [
    #           "Groonga",
    #           2
    #         ],
    #         [
    #           "Senna",
    #           2
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.10. `drilldowns[${LABEL}].columns[${NAME}].stage`

Added in version 7.0.1.

Corresponds to drilldowns[${LABEL}].columns[${NAME}].stage in select. See drilldowns[${LABEL}].columns[${NAME}].stage for details.

Here is an example that creates a dynamic column at `initial` stage. This example creates a dynamic column that stores whether each drilled down tag is occurred only once or not:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].columns[is_popular].stage initial \
      --drilldowns[tag].columns[is_popular].type Bool \
      --drilldowns[tag].columns[is_popular].value '_nsubrecs > 1' \
      --drilldowns[tag].output_columns _key,_nsubrecs,is_popular
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ],
    #           [
    #             "is_popular",
    #             "Bool"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           1,
    #           false
    #         ],
    #         [
    #           "Groonga",
    #           2,
    #           true
    #         ],
    #         [
    #           "Senna",
    #           2,
    #           true
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.11. `drilldowns[${LABEL}].columns[${NAME}].flags`

Added in version 7.0.1.

Corresponds to columns[${NAME}].flags in main search.

The default value is `COLUMN_SCALAR`.

Here is an example that creates a vector column by `COLUMN_VECTOR` flags. `plugin_register functions/vector` is for using vector_new function:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].columns[vector].stage initial \
      --drilldowns[tag].columns[vector].flags COLUMN_VECTOR \
      --drilldowns[tag].columns[vector].type ShortText \
      --drilldowns[tag].columns[vector].value 'vector_new("a", "b", "c")' \
      --drilldowns[tag].output_columns _key,vector
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "vector",
    #             "ShortText"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           [
    #             "a",
    #             "b",
    #             "c"
    #           ]
    #         ],
    #         [
    #           "Groonga",
    #           [
    #             "a",
    #             "b",
    #             "c"
    #           ]
    #         ],
    #         [
    #           "Senna",
    #           [
    #             "a",
    #             "b",
    #             "c"
    #           ]
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.12. `drilldowns[${LABEL}].columns[${NAME}].type`

Added in version 7.0.1.

Corresponds to columns[${NAME}].type in main search.

This is a required parameter.

Here is an example that creates a `ShortText` type column. Stored value is casted to `ShortText` automatically. In this example, number is casted to `ShortText`:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].columns[nsubrecs_string].stage initial \
      --drilldowns[tag].columns[nsubrecs_string].type ShortText \
      --drilldowns[tag].columns[nsubrecs_string].value _nsubrecs \
      --drilldowns[tag].output_columns _key,_nsubrecs,nsubrecs_string
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ],
    #           [
    #             "nsubrecs_string",
    #             "ShortText"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           1,
    #           "1"
    #         ],
    #         [
    #           "Groonga",
    #           2,
    #           "2"
    #         ],
    #         [
    #           "Senna",
    #           2,
    #           "2"
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.13. `drilldowns[${LABEL}].columns[${NAME}].value`

Added in version 7.0.1.

Corresponds to columns[${NAME}].value in main search.

This is a required parameter.

Here is an example that creates a new dynamic column that stores the number of characters of content. This example uses string_length function in `functions/string` plugin to compute the number of characters in a string. plugin_register is used to register `functions/string` plugin:

Execution example:

    plugin_register functions/string \
    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].columns[tag_length].stage initial \
      --drilldowns[tag].columns[tag_length].type UInt32 \
      --drilldowns[tag].columns[tag_length].value 'string_length(_key)' \
      --drilldowns[tag].output_columns _key,tag_length
    # [[0,1337566253.89858,0.000355720520019531],true]

#### 7.3.38.5.9.14. `drilldowns[${LABEL}].columns[${NAME}].window.sort_keys`

Added in version 7.0.1.

Corresponds to columns[${NAME}].window.sort_keys in main search.

You must specify drilldowns[${LABEL}].columns[${NAME}].window.sort_keys or drilldowns[${LABEL}].columns[${NAME}].window.group_keys to use window function.

Here is an example that computes the Nth record in the number of sub records order:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].columns[record_number].stage initial \
      --drilldowns[tag].columns[record_number].type UInt32 \
      --drilldowns[tag].columns[record_number].value 'window_record_number()' \
      --drilldowns[tag].columns[record_number].window.sort_keys _nsubrecs,_key \
      --drilldowns[tag].sort_keys record_number \
      --drilldowns[tag].output_columns _key,_nsubrecs,record_number
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ],
    #           [
    #             "record_number",
    #             "UInt32"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           1,
    #           1
    #         ],
    #         [
    #           "Groonga",
    #           2,
    #           2
    #         ],
    #         [
    #           "Senna",
    #           2,
    #           3
    #         ]
    #       ]
    #     }
    #   ]
    # ]

#### 7.3.38.5.9.15. `drilldowns[${LABEL}].columns[${NAME}].window.group_keys`

Added in version 7.0.1.

Corresponds to columns[${NAME}].window.group_keys in main search.

You must specify drilldowns[${LABEL}].columns[${NAME}].window.sort_keys or drilldowns[${LABEL}].columns[${NAME}].window.group_keys to use window function.

Here is an example that computes the Nth record ordered by tag name for each the same number of sub records:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --limit 0 \
      --output_columns _id \
      --drilldowns[tag].keys tag \
      --drilldowns[tag].columns[record_number].stage initial \
      --drilldowns[tag].columns[record_number].type UInt32 \
      --drilldowns[tag].columns[record_number].value 'window_record_number()' \
      --drilldowns[tag].columns[record_number].window.sort_keys _key \
      --drilldowns[tag].columns[record_number].window.group_keys _nsubrecs \
      --drilldowns[tag].sort_keys _nsubrecs,record_number \
      --drilldowns[tag].output_columns _key,_nsubrecs,record_number
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ]
    #       ]
    #     ],
    #     {
    #       "tag": [
    #         [
    #           3
    #         ],
    #         [
    #           [
    #             "_key",
    #             "ShortText"
    #           ],
    #           [
    #             "_nsubrecs",
    #             "Int32"
    #           ],
    #           [
    #             "record_number",
    #             "UInt32"
    #           ]
    #         ],
    #         [
    #           "Hello",
    #           1,
    #           1
    #         ],
    #         [
    #           "Groonga",
    #           2,
    #           1
    #         ],
    #         [
    #           "Senna",
    #           2,
    #           2
    #         ]
    #       ]
    #     }
    #   ]
    # ]

### 7.3.38.5.10. Cache related parameter

#### 7.3.38.5.10.1. `cache`

Specifies whether caching the result of this query or not.

If the result of this query is cached, the next same query returns response quickly by using the cache.

It doesn’t control whether existing cached result is used or not.

Here are available values:

Value | Description
--- | ---
`no` | Don’t cache the output of this query.
`yes` | Cache the output of this query. It’s the default value.

Here is an example to disable caching the result of this query:

Execution example:

    logical_select \
      --logical_table Entries \
      --shard_key created_at \
      --cache no
    # [
    #   [
    #     0,
    #     1337566253.89858,
    #     0.000355720520019531
    #   ],
    #   [
    #     [
    #       [
    #         5
    #       ],
    #       [
    #         [
    #           "_id",
    #           "UInt32"
    #         ],
    #         [
    #           "_key",
    #           "ShortText"
    #         ],
    #         [
    #           "content",
    #           "Text"
    #         ],
    #         [
    #           "created_at",
    #           "Time"
    #         ],
    #         [
    #           "n_likes",
    #           "UInt32"
    #         ],
    #         [
    #           "tag",
    #           "ShortText"
    #         ]
    #       ],
    #       [
    #         1,
    #         "The first post!",
    #         "Welcome! This is my first post!",
    #         1436281200.0,
    #         5,
    #         "Hello"
    #       ],
    #       [
    #         2,
    #         "Groonga",
    #         "I started to use Groonga. It's very fast!",
    #         1436284800.0,
    #         10,
    #         "Groonga"
    #       ],
    #       [
    #         3,
    #         "Mroonga",
    #         "I also started to use Mroonga. It's also very fast! Really fast!",
    #         1436288400.0,
    #         15,
    #         "Groonga"
    #       ],
    #       [
    #         1,
    #         "Good-bye Senna",
    #         "I migrated all Senna system!",
    #         1436367600.0,
    #         3,
    #         "Senna"
    #       ],
    #       [
    #         2,
    #         "Good-bye Tritonn",
    #         "I also migrated all Tritonn system!",
    #         1436371200.0,
    #         3,
    #         "Senna"
    #       ]
    #     ]
    #   ]
    # ]

The default value is `yes`.

## 7.3.38.6. Return value

The return value format of `logical_select` is compatible with select. See Return value for details.