You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT plaintext_jsonb#>'{field_a,field_b}' FROM examples;
95
+
-- `->` (returns JSON(B))
96
+
SELECT plaintext_jsonb->0FROM examples;
97
97
98
-
-- `#>>` (returns text)
99
-
SELECT plaintext_jsonb#>>'{field_a,field_b}' FROM examples;
98
+
-- `->>` (returns text)
99
+
SELECT plaintext_jsonb->>0FROM examples;
100
100
```
101
101
102
102
### EQL
103
103
104
-
EQL JSONB functions accept an eJSONPath as an argument (instead of using `#>`/`#>>`) for lookups.
105
-
106
-
Note that these are similar to the examples for `->`/`->>`. The difference in these examples is that the path does a lookup multiple levels deep.
104
+
EQL JSONB functions accept an eJSONPath as an argument (instead of using `->`/`->>`) for lookups.
107
105
108
106
#### Decryption example
109
107
110
-
`cs_ste_vec_value_v1` returns the Plaintext EQL payload to the client.
108
+
EQL currently doesn't support returning a specific array element for decryption, but `cs_ste_vec_value_v1` can be used to return an array to the client to process.
109
+
110
+
The query...
111
111
112
112
```sql
113
-
SELECT cs_ste_vec_value_v1(encrypted_jsonb, $1) FROM examples;
113
+
SELECT cs_ste_vec_value_v1(encrypted_jsonb, $1) AS val FROM examples;
114
114
```
115
115
116
+
With the params...
117
+
116
118
```javascript
117
119
// Assume that examples.encrypted_jsonb has JSON objects with
118
120
// the shape:
119
121
{
120
-
"field_a": {
121
-
"field_b":100
122
-
}
122
+
"field_a": [1, 2, 3]
123
123
}
124
124
125
-
// `$1` is the EQL plaintext payload for the eJSONPath `$.field_a.field_b`:
125
+
// `$1` is the EQL plaintext payload for the eJSONPath `$.field_a`:
126
126
{
127
127
"k":"pt",
128
-
"p":"$.field_a.field_b",
128
+
"p":"$.field_a",
129
129
"i": {
130
130
"t":"examples",
131
131
"c":"encrypted_jsonb"
@@ -135,28 +135,50 @@ SELECT cs_ste_vec_value_v1(encrypted_jsonb, $1) FROM examples;
135
135
}
136
136
```
137
137
138
+
Would return the EQL plaintext payload with an array (`[1, 2, 3]` for example):
139
+
140
+
```javascript
141
+
// Example result for a single row
142
+
{
143
+
"k":"pt",
144
+
"p":"[1, 2, 3]",
145
+
"i": {
146
+
"t":"examples",
147
+
"c":"encrypted_jsonb"
148
+
},
149
+
"v":1,
150
+
"q":null
151
+
}
152
+
```
153
+
138
154
#### Comparison example
139
155
140
-
`cs_ste_vec_term_v1` returns an ORE term for comparison.
156
+
`cs_ste_vec_terms_v1` can be used with the native Postgres array access operator to get a term for comparison by array index.
157
+
158
+
The eJSONPath used with `cs_ste_vec_terms_v1` needs to end with `[*]` (`$.some_array_field[*]` for example).
159
+
160
+
> [!IMPORTANT]
161
+
> Array access with `cs_ste_vec_terms_v1` only works when the given eJSONPath only matches a single array.
162
+
> Accessing array elements from `cs_ste_vec_terms_v1` when the eJSONPath matches multiple arrays (for example, when there are nested arrays or multiple arrays at the same depth) can return unexpected results.
163
+
164
+
The following query compares the first item in the array at the eJSONPath in $1 to the value in $2.
SELECT plaintext_jsonb#>>'{field_a,field_b}' FROM examples;
201
213
```
202
214
203
215
### EQL
204
216
205
-
#### Decryption example
217
+
EQL JSONB functions accept an eJSONPath as an argument (instead of using `#>`/`#>>`) for lookups.
206
218
207
-
EQL currently doesn't support returning a `SETOF` values for decryption (for returning a row per item in an array), but `cs_ste_vec_value_v1` can be used to return an array to the client to process.
219
+
Note that these are similar to the examples for `->`/`->>`. The difference in these examples is that the path does a lookup multiple levels deep.
208
220
209
-
The query...
221
+
#### Decryption example
222
+
223
+
`cs_ste_vec_value_v1` returns the Plaintext EQL payload to the client.
210
224
211
225
```sql
212
-
SELECT cs_ste_vec_value_v1(encrypted_jsonb, $1) AS val FROM examples;
226
+
SELECT cs_ste_vec_value_v1(encrypted_jsonb, $1) FROM examples;
213
227
```
214
228
215
-
With the params...
216
-
217
229
```javascript
218
230
// Assume that examples.encrypted_jsonb has JSON objects with
219
231
// the shape:
220
232
{
221
-
"field_a": [1, 2, 3]
233
+
"field_a": {
234
+
"field_b":100
235
+
}
222
236
}
223
237
224
-
// `$1` is the EQL plaintext payload for the eJSONPath `$.field_a`:
238
+
// `$1` is the EQL plaintext payload for the eJSONPath `$.field_a.field_b`:
225
239
{
226
240
"k":"pt",
227
-
"p":"$.field_a",
241
+
"p":"$.field_a.field_b",
228
242
"i": {
229
243
"t":"examples",
230
244
"c":"encrypted_jsonb"
@@ -234,50 +248,28 @@ With the params...
234
248
}
235
249
```
236
250
237
-
Would return the EQL plaintext payload with an array (`[1, 2, 3]` for example):
238
-
239
-
```javascript
240
-
// Example result for a single row
241
-
{
242
-
"k":"pt",
243
-
"p":"[1, 2, 3]",
244
-
"i": {
245
-
"t":"examples",
246
-
"c":"encrypted_jsonb"
247
-
},
248
-
"v":1,
249
-
"q":null
250
-
}
251
-
```
252
-
253
251
#### Comparison example
254
252
255
-
`cs_ste_vec_terms_v1` (note that terms is plural) can be used to return an array of ORE terms for comparison. The array can be `unnest`ed to work with a `SETOF` ORE terms for comparison.
256
-
257
-
The eJSONPath used with `cs_ste_vec_terms_v1` needs to end with `[*]` (`$.some_array_field[*]` for example).
258
-
259
-
Example query:
253
+
`cs_ste_vec_term_v1` returns an ORE term for comparison.
260
254
261
255
```sql
262
-
SELECT id FROM examples e
263
-
WHERE EXISTS (
264
-
SELECT1
265
-
FROM unnest(cs_ste_vec_terms_v1(e.encrypted_jsonb, $1)) AS term
266
-
WHERE term > cs_ste_vec_term_v1($2)
267
-
);
256
+
SELECT*FROM examples
257
+
WHERE cs_ste_vec_term_v1(examples.encrypted_jsonb, $1) > cs_ste_vec_term_v1($2)
268
258
```
269
259
270
260
```javascript
271
261
// Assume that examples.encrypted_jsonb has JSON objects with
272
262
// the shape:
273
263
{
274
-
"field_a": [1, 2, 3]
264
+
"field_a": {
265
+
"field_b":100
266
+
}
275
267
}
276
268
277
-
// `$1` is the EQL plaintext payload for the eJSONPath `$.field_a[*]`:
269
+
// `$1` is the EQL plaintext payload for the eJSONPath `$.field_a.field_b`:
278
270
{
279
271
"k":"pt",
280
-
"p":"$.field_a[*]",
272
+
"p":"$.field_a.field_b",
281
273
"i": {
282
274
"t":"examples",
283
275
"c":"encrypted_jsonb"
@@ -286,10 +278,10 @@ WHERE EXISTS (
286
278
"q":"ejson_path"
287
279
}
288
280
289
-
// `$2` is the EQL plaintext payload for the ORE term to compare against (in this case, the ORE term for the integer `2`):
281
+
// `$2` is the EQL plaintext payload for the ORE term to compare against (in this case, the ORE term for the integer `123`):
EQL JSONB functions accept an eJSONPath as an argument (instead of using `->`/`->>`) for lookups.
317
-
318
318
#### Decryption example
319
319
320
-
EQL currently doesn't support returning a specific array element for decryption, but `cs_ste_vec_value_v1` can be used to return an array to the client to process.
320
+
EQL currently doesn't support returning a `SETOF` values for decryption (for returning a row per item in an array), but `cs_ste_vec_value_v1` can be used to return an array to the client to process.
321
321
322
322
The query...
323
323
@@ -365,26 +365,26 @@ Would return the EQL plaintext payload with an array (`[1, 2, 3]` for example):
365
365
366
366
#### Comparison example
367
367
368
-
`cs_ste_vec_terms_v1` can be used with the native Postgres array access operator to get a term for comparison by array index.
368
+
`cs_ste_vec_terms_v1`(note that terms is plural) can be used to return an array of ORE terms for comparison. The array can be `unnest`ed to work with a `SETOF` ORE terms for comparison.
369
369
370
370
The eJSONPath used with `cs_ste_vec_terms_v1` needs to end with `[*]` (`$.some_array_field[*]` for example).
371
371
372
-
> [!IMPORTANT]
373
-
> Array access with `cs_ste_vec_terms_v1` only works when the given eJSONPath only matches a single array.
374
-
> Accessing array elements from `cs_ste_vec_terms_v1` when the eJSONPath matches multiple arrays (for example, when there are nested arrays or multiple arrays at the same depth) can return unexpected results.
375
-
376
-
The following query compares the first item in the array at the eJSONPath in $1 to the value in $2.
372
+
Example query:
377
373
378
374
```sql
379
-
SELECT*FROM examples
380
-
WHERE (cs_ste_vec_terms_v1(examples.encrypted_jsonb, $1))[1] > cs_ste_vec_term_v1($2)
375
+
SELECT id FROM examples e
376
+
WHERE EXISTS (
377
+
SELECT1
378
+
FROM unnest(cs_ste_vec_terms_v1(e.encrypted_jsonb, $1)) AS term
379
+
WHERE term > cs_ste_vec_term_v1($2)
380
+
);
381
381
```
382
382
383
383
```javascript
384
384
// Assume that examples.encrypted_jsonb has JSON objects with
385
385
// the shape:
386
386
{
387
-
"field_a": [4, 5, 6]
387
+
"field_a": [1, 2, 3]
388
388
}
389
389
390
390
// `$1` is the EQL plaintext payload for the eJSONPath `$.field_a[*]`:
@@ -399,10 +399,10 @@ WHERE (cs_ste_vec_terms_v1(examples.encrypted_jsonb, $1))[1] > cs_ste_vec_term_v
399
399
"q":"ejson_path"
400
400
}
401
401
402
-
// `$2` is the EQL plaintext payload for the ORE term to compare against (in this case, the ORE term for the integer `3`):
402
+
// `$2` is the EQL plaintext payload for the ORE term to compare against (in this case, the ORE term for the integer `2`):
0 commit comments