From af954322cfc645e5066ce5bf76b31d069b7e7fd4 Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Tue, 13 Aug 2019 14:54:52 -0500 Subject: [PATCH 1/2] Minor fixes to query language docs --- docs/query-language.md | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/docs/query-language.md b/docs/query-language.md index 0064401cc..d6f071450 100644 --- a/docs/query-language.md +++ b/docs/query-language.md @@ -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(, previous=, limit=, column=, 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 @@ -863,7 +864,7 @@ Rows(blahk) **Spec:** ``` -GroupBy(, [RowsCall...], limit=, filter=) +GroupBy(, [...], limit=, filter=) ``` **Description:** @@ -925,3 +926,12 @@ GroupBy(Rows(blah, previous=39), Rows(blahk, previous="haha"), limit=7) [{"group":[{"field":"blah","rowID":39},{"field":"blahk","rowKey":"zaaa"}],"count":1}, {"group":[{"field":"blah","rowID":39},{"field":"blahk","rowKey":"traa"}],"count":1}] ``` + +Using the filter argument. +```request +GroupBy(Rows(blah, previous=39), Rows(blahk, previous="haha"), limit=7, filter=Row(age=22)) +``` + +```response +TODO +``` From f7554a3cd4a9035432ab611cd6c0f2a80b8b7d7c Mon Sep 17 00:00:00 2001 From: Alan Bernstein Date: Wed, 14 Aug 2019 11:37:21 -0500 Subject: [PATCH 2/2] Add GroupBy filter response, use sensible field names --- docs/query-language.md | 48 ++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/docs/query-language.md b/docs/query-language.md index d6f071450..f8b3d7dd0 100644 --- a/docs/query-language.md +++ b/docs/query-language.md @@ -845,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 @@ -895,43 +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(blah, previous=39), Rows(blahk, previous="haha"), limit=7, filter=Row(age=22)) +GroupBy(Rows(age), Rows(job), limit=7, filter=Row(country=USA)) ``` ```response -TODO +[{"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}] ```