Merge pull request #2054 from alanbernstein/query-language-fixes

Minor fixes to query language docs
This commit is contained in:
alanbernstein 2019-09-17 11:27:34 -05:00 • committed by GitHub
commit f1216fd35d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,14 +44,15 @@ curl localhost:10101/index/repository/query \
#### Arguments and Types
* `field` The field specifies on which Pilosa [field](../glossary/#field) the query will operate. Valid field names are lower case strings; they start with a lowercase letter, and contain only alphanumeric characters and `_-`. They must be 64 characters or less in length.
* `TIMESTAMP` This is a timestamp in the following format `YYYY-MM-DDTHH:MM` (e.g. 2006-01-02T15:04)
* `UINT` An unsigned integer (e.g. 42839)
* `BOOL` A boolean value, `true` or `false`
* `ATTR_NAME` Must be a valid identifier `[A-Za-z][A-Za-z0-9._-]*`
* `TIMESTAMP` This is a timestamp in the following format `YYYY-MM-DDTHH:MM` (e.g. 2006-01-02T15:04).
* `UINT` An unsigned integer (e.g. 42839).
* `BOOL` A boolean value, `true` or `false`.
* `ATTR_NAME` Must be a valid identifier `[A-Za-z][A-Za-z0-9._-]*`.
* `ATTR_VALUE` Can be a string, float, integer, or bool.
* `CALL` Any query
* `ROW_CALL` Any query which returns a row, such as `Row`, `Union`, `Difference`, `Xor`, `Intersect`, `Not`
* `[]ATTR_VALUE` Denotes an array of `ATTR_VALUE`s. (e.g. `["a", "b", "c"]`)
* `CALL` Any query.
* `ROW_CALL` Any query which returns a row, such as `Row`, `Union`, `Difference`, `Xor`, `Intersect`, `Not`.
* `ROWS_CALL` A query that returns a `Rows` result (i.e. a list of row IDs). Currently only the `Rows` query.
* `[]ATTR_VALUE` Denotes an array of `ATTR_VALUE`s. (e.g. `["a", "b", "c"]`).
### Write Operations
@ -823,7 +824,7 @@ Rows(<FIELD>, previous=<UINT|STRING>, limit=<UINT>, column=<UINT|STRING>, from=<
**Description:**
Rows returns a list of row IDs in the given field which have at least one bit
set. The field argument is mandatory, the others are optional.
set. The field argument is mandatory, the others are optional.
If `previous` is given, rows prior to and including the specified row ID or
key will not be returned. If `column` is given, only rows which have a set bit
@ -844,18 +845,18 @@ not provided, the full range of existing data will be queried.
Without keys:
```request
Rows(blah)
Rows(age)
```
```response
{"rows":[1,9,39]}
{"rows":[18,22,29]}
```
With keys:
```request
Rows(blahk)
Rows(job)
```
```response
{"rows":null,"keys":["haha","zaaa","traa"]}
{"rows":null,"keys":["engineer","management","student""]}
```
#### Group By
@ -863,7 +864,7 @@ Rows(blahk)
**Spec:**
```
GroupBy(<RowsCall>, [RowsCall...], limit=<UINT>, filter=<CALL>)
GroupBy(<ROWS_CALL>, [<ROWS_CALL>...], limit=<UINT>, filter=<ROW_CALL>)
```
**Description:**
@ -894,34 +895,49 @@ specify the field and row for each row that was intersected to get that result.
A single `Rows` query.
```request
GroupBy(Rows(blah))
GroupBy(Rows(age))
```
```response
[{"group":[{"field":"blah","rowID":1}],"count":1},
{"group":[{"field":"blah","rowID":9}],"count":1},
{"group":[{"field":"blah","rowID":39}],"count":1}]
[{"group":[{"field":"age","rowID":18}],"count":14},
{"group":[{"field":"age","rowID":22}],"count":22},
{"group":[{"field":"age","rowID":29}],"count":6}]
```
With two `Rows` queries - one with IDs and one with keys.
```request
GroupBy(Rows(blah), Rows(blahk), limit=7)
GroupBy(Rows(age), Rows(job), limit=7)
```
```response
[{"group":[{"field":"blah","rowID":1},{"field":"blahk","rowKey":"haha"}],"count":1},
{"group":[{"field":"blah","rowID":1},{"field":"blahk","rowKey":"zaaa"}],"count":1},
{"group":[{"field":"blah","rowID":1},{"field":"blahk","rowKey":"traa"}],"count":1},
{"group":[{"field":"blah","rowID":9},{"field":"blahk","rowKey":"haha"}],"count":1},
{"group":[{"field":"blah","rowID":9},{"field":"blahk","rowKey":"zaaa"}],"count":1},
{"group":[{"field":"blah","rowID":9},{"field":"blahk","rowKey":"traa"}],"count":1},
{"group":[{"field":"blah","rowID":39},{"field":"blahk","rowKey":"haha"}],"count":1}]
[{"group":[{"field":"age","rowID":18},{"field":"job","rowKey":"engineer"}],"count":3},
{"group":[{"field":"age","rowID":18},{"field":"job","rowKey":"management"}],"count":1},
{"group":[{"field":"age","rowID":18},{"field":"job","rowKey":"student"}],"count":11},
{"group":[{"field":"age","rowID":22},{"field":"job","rowKey":"engineer"}],"count":6},
{"group":[{"field":"age","rowID":22},{"field":"job","rowKey":"management"}],"count":2},
{"group":[{"field":"age","rowID":22},{"field":"job","rowKey":"student"}],"count":4},
{"group":[{"field":"age","rowID":29},{"field":"job","rowKey":"engineer"}],"count":9}]
```
Getting the rest of the results from the previous example (paging).
```request
GroupBy(Rows(blah, previous=39), Rows(blahk, previous="haha"), limit=7)
GroupBy(Rows(age, previous=29), Rows(job, previous="management"), limit=7)
```
```response
[{"group":[{"field":"blah","rowID":39},{"field":"blahk","rowKey":"zaaa"}],"count":1},
{"group":[{"field":"blah","rowID":39},{"field":"blahk","rowKey":"traa"}],"count":1}]
{"group":[{"field":"age","rowID":29},{"field":"job","rowKey":"engineer"}],"count":9}]
[{"group":[{"field":"age","rowID":29},{"field":"job","rowKey":"management"}],"count":3},
{"group":[{"field":"age","rowID":29},{"field":"job","rowKey":"student"}],"count":1}]
```
Using the filter argument.
```request
GroupBy(Rows(age), Rows(job), limit=7, filter=Row(country=USA))
```
```response
[{"group":[{"field":"age","rowID":18},{"field":"job","rowKey":"engineer"}],"count":1},
{"group":[{"field":"age","rowID":18},{"field":"job","rowKey":"student"}],"count":6},
{"group":[{"field":"age","rowID":22},{"field":"job","rowKey":"engineer"}],"count":3},
{"group":[{"field":"age","rowID":22},{"field":"job","rowKey":"management"}],"count":1},
{"group":[{"field":"age","rowID":22},{"field":"job","rowKey":"student"}],"count":3},
{"group":[{"field":"age","rowID":29},{"field":"job","rowKey":"management"}],"count":7}]
```