Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean warnings #184

Merged
merged 55 commits into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
af34b9c
delete mock
shacharPash Aug 10, 2023
ff101b5
coverage
shacharPash Aug 10, 2023
c2b5fe6
fix test
shacharPash Aug 10, 2023
f8f2aec
indent
shacharPash Aug 13, 2023
dbe0b74
Merge branch 'master' into DeleteMoq
shacharPash Aug 14, 2023
27a69c0
change to var - check
shacharPash Aug 14, 2023
dc0d3c0
cluster test
shacharPash Aug 14, 2023
eeb2edf
add opthin to connect cluster with dotnet test
shacharPash Aug 15, 2023
0d100d7
use key in topk tests
shacharPash Aug 16, 2023
53c0163
Merge branch 'master' into ClusterSupport
shacharPash Aug 16, 2023
02d1837
get env vars inside RedisFixture
shacharPash Aug 22, 2023
5ace5b9
Merge branch 'master' into ClusterSupport
shacharPash Aug 22, 2023
65a49b6
skip if redis
shacharPash Aug 22, 2023
c7b6cd9
add skip where needed
shacharPash Aug 24, 2023
6e82630
Execute broadcast
shacharPash Aug 24, 2023
b5cdf87
delete cluster tests
shacharPash Aug 24, 2023
376ccdf
RedisFixture fix
shacharPash Aug 24, 2023
495dce1
add to contributing
shacharPash Aug 24, 2023
47e2d7f
run cluster on CI
shacharPash Aug 28, 2023
d87cec0
wip
shacharPash Aug 28, 2023
b933427
fix /
shacharPash Aug 28, 2023
ccb7625
-d
shacharPash Aug 28, 2023
908699d
delete restore
shacharPash Aug 28, 2023
b5318bf
return restore
shacharPash Aug 28, 2023
31bef69
add -RC3
shacharPash Aug 30, 2023
e544fe0
add RC3 to docker-compose
shacharPash Aug 30, 2023
5f67f42
try define both .net 6 and 7
shacharPash Aug 30, 2023
9724f9b
Skip if cluster where needed
shacharPash Aug 31, 2023
d998125
add names
shacharPash Aug 31, 2023
2842a29
skip configOnTimeout if cluster
shacharPash Aug 31, 2023
d07f225
try to fix win tests
shacharPash Aug 31, 2023
661cb1c
tests names +fix win version
shacharPash Aug 31, 2023
b4a5ff2
fix versions
shacharPash Aug 31, 2023
6c98a16
versions
shacharPash Aug 31, 2023
b1feed4
win verer
shacharPash Aug 31, 2023
3b79773
wording
shacharPash Aug 31, 2023
ad44131
Merge branch 'master' into ClusterSupport
chayim Sep 3, 2023
341161a
Merge branch 'master' into ClusterSupport
chayim Sep 10, 2023
36d32dd
Merge branch 'master' into ClusterSupport
shacharPash Sep 10, 2023
bff96ca
dotnet format
shacharPash Sep 10, 2023
a42fee6
Clean Warnings
shacharPash Sep 11, 2023
e95f68c
dataType not nullable
shacharPash Sep 11, 2023
0c0910e
cleaning
shacharPash Sep 11, 2023
af1b585
TS warnings
shacharPash Sep 11, 2023
9c56265
all warnings?
shacharPash Sep 11, 2023
a488f2a
more fixes
shacharPash Sep 11, 2023
34e7b35
string format error
shacharPash Sep 11, 2023
c01f7ee
warnings
shacharPash Sep 11, 2023
3b90ba0
more
shacharPash Sep 11, 2023
c826f0c
merge with master
shacharPash Sep 26, 2023
ed33204
format
shacharPash Sep 26, 2023
a353196
clean all warnings?
shacharPash Sep 26, 2023
2c5dab6
fix more warnings
shacharPash Sep 27, 2023
c3c369d
clean almost all warnings
shacharPash Sep 27, 2023
1ca4abb
hope its all
shacharPash Sep 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 75 additions & 14 deletions Examples/AdvancedJsonExamples.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
# Advanced JSON

Redis JSON array filtering examples

## Contents
1. [Business Value Statement](#value)
2. [Data Set](#dataset)
3. [Data Loading](#dataload)
4. [Array Filtering Examples](#arrayfiltering)
1. [All Properties of Array](#allprops)
2. [All Properties of a Field](#allfield)
3. [Relational - Equality](#equality)
4. [Relational - Less Than](#lessthan)
5. [Relational - Greater Than or Equal](#greaterthan)
6. [Logical AND](#logicaland)
7. [Logical OR](#logicalor)
8. [Regex - Contains Exact](#regex_exact)
9. [Regex - Contains, Case Insensitive](#regex_contains)
10. [Regex - Begins With](#regex_begins)

1. [Business Value Statement](#value)
2. [Data Set](#dataset)
3. [Data Loading](#dataload)
4. [Array Filtering Examples](#arrayfiltering)
1. [All Properties of Array](#allprops)
2. [All Properties of a Field](#allfield)
3. [Relational - Equality](#equality)
4. [Relational - Less Than](#lessthan)
5. [Relational - Greater Than or Equal](#greaterthan)
6. [Logical AND](#logicaland)
7. [Logical OR](#logicalor)
8. [Regex - Contains Exact](#regex_exact)
9. [Regex - Contains, Case Insensitive](#regex_contains)
10. [Regex - Begins With](#regex_begins)

## Business Value Statement <a name="value"></a>

The ability to query within a JSON object unlocks further value to the underlying data. Redis supports JSONPath array filtering natively.

## Data Set <a name="dataset"></a>

```JSON
{
"city": "Boston",
Expand Down Expand Up @@ -48,7 +54,9 @@ The ability to query within a JSON object unlocks further value to the underlyin
]
}
```

## Data Loading <a name="dataload"></a>

```c#
JsonCommands json = db.JSON();
json.Set("warehouse:1", "$", new {
Expand Down Expand Up @@ -79,21 +87,29 @@ json.Set("warehouse:1", "$", new {
}
});
```

## Array Filtering Examples <a name="arrayfiltering"></a>

### Syntax

[JSON.GET](https://redis.io/commands/json.get/)

### All Properties of Array <a name="allprops"></a>

Fetch all properties of an array.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[*]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand Down Expand Up @@ -131,16 +147,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### All Properties of a Field <a name="allfield"></a>

Fetch all values of a field within an array.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[*].price",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
34.95,
Expand All @@ -150,16 +171,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Relational - Equality <a name="equality"></a>

Fetch all items within an array where a text field matches a given value.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.description==\"Turtle Check Men Navy Blue Shirt\")]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand All @@ -176,16 +202,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Relational - Less Than <a name="lessthan"></a>

Fetch all items within an array where a numeric field is less than a given value.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.price<100)]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand All @@ -211,16 +242,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Relational - Greater Than or Equal <a name="greaterthan"></a>

Fetch all items within an array where a numeric field is greater than or equal to a given value.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.id>=20000)]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand Down Expand Up @@ -248,16 +284,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Logical AND <a name="logicaland"></a>

Fetch all items within an array that meet two relational operations.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.gender==\"Men\"&&@.price>20)]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand All @@ -274,16 +315,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Logical OR <a name="logicalor"></a>

Fetch all items within an array that meet at least one relational operation. In this case, return only the ids of those items.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.price<100||@.gender==\"Women\")].id",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
15970,
Expand All @@ -293,16 +339,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Regex - Contains Exact <a name="regex_exact"></a>

Fetch all items within an array that match a given regex pattern.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.description =~ \"Blue\")]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand All @@ -328,16 +379,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Regex - Contains, Case Insensitive <a name="regex_contains"></a>

Fetch all items within an array where a field contains a term, case insensitive.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.description =~ \"(?i)watch\")]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand All @@ -356,16 +412,21 @@ Console.WriteLine(json.Get(key: "warehouse:1",
```

### Regex - Begins With <a name="regex_begins"></a>

Fetch all items within an array where a field begins with a given expression.

#### Command

```c#
Console.WriteLine(json.Get(key: "warehouse:1",
path: "$.inventory[?(@.description =~ \"^T\")]",
indent: "\t",
newLine: "\n"
));
```

#### Result

```json
[
{
Expand Down
Loading