Skip to content

Commit cfeb817

Browse files
shacharPashchayim
andauthored
Clean warnings (#184)
* delete mock * coverage * fix test * indent * change to var - check * cluster test * add opthin to connect cluster with dotnet test * use key in topk tests * get env vars inside RedisFixture * skip if redis * add skip where needed * Execute broadcast * delete cluster tests * RedisFixture fix * add to contributing * run cluster on CI * wip * fix / * -d * delete restore * return restore * add -RC3 * add RC3 to docker-compose * try define both .net 6 and 7 * Skip if cluster where needed * add names * skip configOnTimeout if cluster * try to fix win tests * tests names +fix win version * fix versions * versions * win verer * wording * dotnet format * Clean Warnings * dataType not nullable * cleaning * TS warnings * all warnings? * more fixes * string format error * warnings * more * format * clean all warnings? * fix more warnings * clean almost all warnings * hope its all --------- Co-authored-by: Chayim <[email protected]>
1 parent ac897cc commit cfeb817

File tree

98 files changed

+1196
-728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1196
-728
lines changed

Examples/AdvancedJsonExamples.md

+75-14
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,30 @@
11
# Advanced JSON
2+
23
Redis JSON array filtering examples
4+
35
## Contents
4-
1. [Business Value Statement](#value)
5-
2. [Data Set](#dataset)
6-
3. [Data Loading](#dataload)
7-
4. [Array Filtering Examples](#arrayfiltering)
8-
1. [All Properties of Array](#allprops)
9-
2. [All Properties of a Field](#allfield)
10-
3. [Relational - Equality](#equality)
11-
4. [Relational - Less Than](#lessthan)
12-
5. [Relational - Greater Than or Equal](#greaterthan)
13-
6. [Logical AND](#logicaland)
14-
7. [Logical OR](#logicalor)
15-
8. [Regex - Contains Exact](#regex_exact)
16-
9. [Regex - Contains, Case Insensitive](#regex_contains)
17-
10. [Regex - Begins With](#regex_begins)
6+
7+
1. [Business Value Statement](#value)
8+
2. [Data Set](#dataset)
9+
3. [Data Loading](#dataload)
10+
4. [Array Filtering Examples](#arrayfiltering)
11+
1. [All Properties of Array](#allprops)
12+
2. [All Properties of a Field](#allfield)
13+
3. [Relational - Equality](#equality)
14+
4. [Relational - Less Than](#lessthan)
15+
5. [Relational - Greater Than or Equal](#greaterthan)
16+
6. [Logical AND](#logicaland)
17+
7. [Logical OR](#logicalor)
18+
8. [Regex - Contains Exact](#regex_exact)
19+
9. [Regex - Contains, Case Insensitive](#regex_contains)
20+
10. [Regex - Begins With](#regex_begins)
1821

1922
## Business Value Statement <a name="value"></a>
23+
2024
The ability to query within a JSON object unlocks further value to the underlying data. Redis supports JSONPath array filtering natively.
25+
2126
## Data Set <a name="dataset"></a>
27+
2228
```JSON
2329
{
2430
"city": "Boston",
@@ -48,7 +54,9 @@ The ability to query within a JSON object unlocks further value to the underlyin
4854
]
4955
}
5056
```
57+
5158
## Data Loading <a name="dataload"></a>
59+
5260
```c#
5361
JsonCommands json = db.JSON();
5462
json.Set("warehouse:1", "$", new {
@@ -79,21 +87,29 @@ json.Set("warehouse:1", "$", new {
7987
}
8088
});
8189
```
90+
8291
## Array Filtering Examples <a name="arrayfiltering"></a>
92+
8393
### Syntax
94+
8495
[JSON.GET](https://redis.io/commands/json.get/)
8596

8697
### All Properties of Array <a name="allprops"></a>
98+
8799
Fetch all properties of an array.
100+
88101
#### Command
102+
89103
```c#
90104
Console.WriteLine(json.Get(key: "warehouse:1",
91105
path: "$.inventory[*]",
92106
indent: "\t",
93107
newLine: "\n"
94108
));
95109
```
110+
96111
#### Result
112+
97113
```json
98114
[
99115
{
@@ -131,16 +147,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
131147
```
132148

133149
### All Properties of a Field <a name="allfield"></a>
150+
134151
Fetch all values of a field within an array.
152+
135153
#### Command
154+
136155
```c#
137156
Console.WriteLine(json.Get(key: "warehouse:1",
138157
path: "$.inventory[*].price",
139158
indent: "\t",
140159
newLine: "\n"
141160
));
142161
```
162+
143163
#### Result
164+
144165
```json
145166
[
146167
34.95,
@@ -150,16 +171,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
150171
```
151172

152173
### Relational - Equality <a name="equality"></a>
174+
153175
Fetch all items within an array where a text field matches a given value.
176+
154177
#### Command
178+
155179
```c#
156180
Console.WriteLine(json.Get(key: "warehouse:1",
157181
path: "$.inventory[?(@.description==\"Turtle Check Men Navy Blue Shirt\")]",
158182
indent: "\t",
159183
newLine: "\n"
160184
));
161185
```
186+
162187
#### Result
188+
163189
```json
164190
[
165191
{
@@ -176,16 +202,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
176202
```
177203

178204
### Relational - Less Than <a name="lessthan"></a>
205+
179206
Fetch all items within an array where a numeric field is less than a given value.
207+
180208
#### Command
209+
181210
```c#
182211
Console.WriteLine(json.Get(key: "warehouse:1",
183212
path: "$.inventory[?(@.price<100)]",
184213
indent: "\t",
185214
newLine: "\n"
186215
));
187216
```
217+
188218
#### Result
219+
189220
```json
190221
[
191222
{
@@ -211,16 +242,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
211242
```
212243

213244
### Relational - Greater Than or Equal <a name="greaterthan"></a>
245+
214246
Fetch all items within an array where a numeric field is greater than or equal to a given value.
247+
215248
#### Command
249+
216250
```c#
217251
Console.WriteLine(json.Get(key: "warehouse:1",
218252
path: "$.inventory[?(@.id>=20000)]",
219253
indent: "\t",
220254
newLine: "\n"
221255
));
222256
```
257+
223258
#### Result
259+
224260
```json
225261
[
226262
{
@@ -248,16 +284,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
248284
```
249285

250286
### Logical AND <a name="logicaland"></a>
287+
251288
Fetch all items within an array that meet two relational operations.
289+
252290
#### Command
291+
253292
```c#
254293
Console.WriteLine(json.Get(key: "warehouse:1",
255294
path: "$.inventory[?(@.gender==\"Men\"&&@.price>20)]",
256295
indent: "\t",
257296
newLine: "\n"
258297
));
259298
```
299+
260300
#### Result
301+
261302
```json
262303
[
263304
{
@@ -274,16 +315,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
274315
```
275316

276317
### Logical OR <a name="logicalor"></a>
318+
277319
Fetch all items within an array that meet at least one relational operation. In this case, return only the ids of those items.
320+
278321
#### Command
322+
279323
```c#
280324
Console.WriteLine(json.Get(key: "warehouse:1",
281325
path: "$.inventory[?(@.price<100||@.gender==\"Women\")].id",
282326
indent: "\t",
283327
newLine: "\n"
284328
));
285329
```
330+
286331
#### Result
332+
287333
```json
288334
[
289335
15970,
@@ -293,16 +339,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
293339
```
294340

295341
### Regex - Contains Exact <a name="regex_exact"></a>
342+
296343
Fetch all items within an array that match a given regex pattern.
344+
297345
#### Command
346+
298347
```c#
299348
Console.WriteLine(json.Get(key: "warehouse:1",
300349
path: "$.inventory[?(@.description =~ \"Blue\")]",
301350
indent: "\t",
302351
newLine: "\n"
303352
));
304353
```
354+
305355
#### Result
356+
306357
```json
307358
[
308359
{
@@ -328,16 +379,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
328379
```
329380

330381
### Regex - Contains, Case Insensitive <a name="regex_contains"></a>
382+
331383
Fetch all items within an array where a field contains a term, case insensitive.
384+
332385
#### Command
386+
333387
```c#
334388
Console.WriteLine(json.Get(key: "warehouse:1",
335389
path: "$.inventory[?(@.description =~ \"(?i)watch\")]",
336390
indent: "\t",
337391
newLine: "\n"
338392
));
339393
```
394+
340395
#### Result
396+
341397
```json
342398
[
343399
{
@@ -356,16 +412,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
356412
```
357413

358414
### Regex - Begins With <a name="regex_begins"></a>
415+
359416
Fetch all items within an array where a field begins with a given expression.
417+
360418
#### Command
419+
361420
```c#
362421
Console.WriteLine(json.Get(key: "warehouse:1",
363422
path: "$.inventory[?(@.description =~ \"^T\")]",
364423
indent: "\t",
365424
newLine: "\n"
366425
));
367426
```
427+
368428
#### Result
429+
369430
```json
370431
[
371432
{

0 commit comments

Comments
 (0)