|
16 | 16 |
|
17 | 17 | abstract class Query { |
18 | 18 | /** |
19 | | - The `FROM` source command returns a table with data from a data stream, |
20 | | - index, or alias. |
| 19 | + * The `FROM` source command returns a table with data from a data stream, |
| 20 | + * index, or alias. |
21 | 21 | * |
22 | | - @param string $indices A list of indices, data streams or aliases. Supports |
23 | | - wildcards and date math. |
| 22 | + * @param string $indices A list of indices, data streams or aliases. Supports |
| 23 | + * wildcards and date math. |
24 | 24 | * |
25 | | - Examples: |
| 25 | + * Examples: |
26 | 26 | * |
27 | | - $query1 = Query::from("employees"); |
28 | | - $query2 = Query::from("<logs-{now/d}>"); |
29 | | - $query3 = Query::from("employees-00001", "other-employees-*"); |
30 | | - $query4 = Query::from("cluster_one:employees-00001", "cluster_two:other-employees-*"); |
31 | | - $query5 = Query::from("employees")->metadata("_id"); |
| 27 | + * $query1 = Query::from("employees"); |
| 28 | + * $query2 = Query::from("<logs-{now/d}>"); |
| 29 | + * $query3 = Query::from("employees-00001", "other-employees-*"); |
| 30 | + * $query4 = Query::from("cluster_one:employees-00001", "cluster_two:other-employees-*"); |
| 31 | + * $query5 = Query::from("employees")->metadata("_id"); |
32 | 32 | */ |
33 | 33 | public static function from(string ...$indices): FromCommand |
34 | 34 | { |
35 | 35 | return new FromCommand($indices); |
36 | 36 | } |
37 | 37 |
|
38 | 38 | /** |
39 | | - The ``ROW`` source command produces a row with one or more columns with |
40 | | - values that you specify. This can be useful for testing. |
| 39 | + * The ``ROW`` source command produces a row with one or more columns with |
| 40 | + * values that you specify. This can be useful for testing. |
41 | 41 | * |
42 | | - @param string ...$params the column values to produce, given as keyword |
43 | | - arguments. |
| 42 | + * @param string ...$params the column values to produce, given as keyword |
| 43 | + * arguments. |
44 | 44 | * |
45 | | - Examples: |
| 45 | + * Examples: |
46 | 46 | * |
47 | | - $query1 = Query::row(a: 1, b: "two", c: null); |
48 | | - $query2 = Query::row(a: [2, 1]); |
| 47 | + * $query1 = Query::row(a: 1, b: "two", c: null); |
| 48 | + * $query2 = Query::row(a: [2, 1]); |
49 | 49 | */ |
50 | 50 | public static function row(mixed ...$params): RowCommand |
51 | 51 | { |
52 | 52 | return new RowCommand($params); |
53 | 53 | } |
54 | 54 |
|
55 | 55 | /** |
56 | | - The `SHOW` source command returns information about the deployment and |
57 | | - its capabilities. |
| 56 | + * The `SHOW` source command returns information about the deployment and |
| 57 | + * its capabilities. |
58 | 58 | * |
59 | | - @param string $item Can only be `INFO`. |
| 59 | + * @param string $item Can only be `INFO`. |
60 | 60 | * |
61 | | - Examples: |
| 61 | + * Examples: |
62 | 62 | * |
63 | | - $query = Query::show("INFO"); |
| 63 | + * $query = Query::show("INFO"); |
64 | 64 | */ |
65 | 65 | public static function show(string $item): ShowCommand |
66 | 66 | { |
67 | 67 | return new ShowCommand($item); |
68 | 68 | } |
69 | 69 |
|
70 | 70 | /** |
71 | | - This method can only be used inside a `FORK` command to create each branch. |
| 71 | + * The `TS` source command is similar to ``FROM``, but for time series indices. |
72 | 72 | * |
73 | | - Examples: |
| 73 | + * @param string $indices A list of indices, data streams or aliases. Supports |
| 74 | + * wildcards and date math. |
74 | 75 | * |
75 | | - $query = Query::from("employees") |
76 | | - ->fork( |
77 | | - Query::branch()->where("emp_no == 10001"), |
78 | | - Query::branch()->where("emp_no == 10002"), |
79 | | - ) |
| 76 | + * Examples: |
| 77 | + * |
| 78 | + * $query = Query::ts("metrics") |
| 79 | + * ->where("@timestamp >= now() - 1 day") |
| 80 | + * ->stats("SUM(AVG_OVER_TIME(memory_usage))").by("host", "TBUCKET(1 hour)") |
| 81 | + */ |
| 82 | + public static function ts(string ...$indices): TSCommand |
| 83 | + { |
| 84 | + return new TSCommand($indices); |
| 85 | + } |
| 86 | + |
| 87 | + /** |
| 88 | + * This method can only be used inside a `FORK` command to create each branch. |
| 89 | + * |
| 90 | + * Examples: |
| 91 | + * |
| 92 | + * $query = Query::from("employees") |
| 93 | + * ->fork( |
| 94 | + * Query::branch()->where("emp_no == 10001"), |
| 95 | + * Query::branch()->where("emp_no == 10002"), |
| 96 | + * ) |
80 | 97 | */ |
81 | 98 | public static function branch(): Branch |
82 | 99 | { |
|
0 commit comments