From e372cddd1565a6a34f41526d844110b11ae369c9 Mon Sep 17 00:00:00 2001 From: Shachar Pashchur Date: Tue, 29 Nov 2022 17:14:45 +0200 Subject: [PATCH 1/7] Changing 'Modules' to 'Stack' --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 55ebc2d6..f331ba5e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ## Note -This project builds on [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis), and seeks to bring native support for Redis Modules to the C# ecosystem. +This project builds on [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis), and seeks to bring native support for Redis Stack commands to the C# ecosystem. ## API @@ -18,7 +18,7 @@ The complete documentation for Redis module commands can be found at the [Redis ### Redis OSS commands You can use Redis OSS commands in the same way as you use them in [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis). -### Modules Commands +### Stack Commands Each module has a command class with its own commands. The supported modules are: [Search](https://redis.io/commands/?group=search), [Json](https://redis.io/commands/?group=json), [Graph](https://redis.io/commands/?group=graph), [TimeSeries](https://redis.io/commands/?group=timeseries), [Bloom Filter](https://redis.io/commands/?group=bf), [Cuckoo Filter](https://redis.io/commands/?group=cf), [T-Digest](https://redis.io/commands/?group=tdigest), [Count-min Sketch](https://redis.io/commands/?group=cms) and [Top-K](https://redis.io/commands/?group=topk). From 129f5c8e19e7a9678146d394d01afdb3091cca4d Mon Sep 17 00:00:00 2001 From: Shachar Pashchur Date: Tue, 29 Nov 2022 17:36:24 +0200 Subject: [PATCH 2/7] Adding installation & getting started guide --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f331ba5e..a5625785 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,29 @@ The supported modules are: [Search](https://redis.io/commands/?group=search), [J # Usage -First, you need to connect to Redis, exactly the same way you do it in [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis): +## 💻 Installation + +Using the dotnet cli, run: + +```text +dotnet add package NRedisStack +``` + +## 🏁 Getting started + +### Starting Redis + +Before writing any code you'll need a Redis instance with the appropriate Redis modules! The quickest way to get this is with Docker: + +```sh +docker run -p 6379:6379 -p 8001:8001 redis/redis-stack +``` + +This launches the [redis-stack](https://redis.io/docs/stack/) an extension of Redis that adds all manner of modern data structures to Redis. You'll also notice that if you open up http://localhost:8001 you'll have access to the redis-insight GUI, a GUI you can use to visualize and work with your data in Redis. + +Now, you need to connect to Redis, exactly the same way you do it in [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis): ```csharp -using StackExchange.Redis; +using NRedisStack; ... ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); ``` From e2dcfb32e6148eaf2b4f98a4f4b9d371da93ebdc Mon Sep 17 00:00:00 2001 From: Shachar Pashchur Date: Tue, 29 Nov 2022 18:13:51 +0200 Subject: [PATCH 3/7] Update Docker --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5625785..d26619d8 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ dotnet add package NRedisStack Before writing any code you'll need a Redis instance with the appropriate Redis modules! The quickest way to get this is with Docker: ```sh -docker run -p 6379:6379 -p 8001:8001 redis/redis-stack +docker run -p 6379:6379 --name redis-stack redis/redis-stack:latest ``` This launches the [redis-stack](https://redis.io/docs/stack/) an extension of Redis that adds all manner of modern data structures to Redis. You'll also notice that if you open up http://localhost:8001 you'll have access to the redis-insight GUI, a GUI you can use to visualize and work with your data in Redis. From 21a4fc6c75aa4b4d1e1d9e44568fb6f63c281767 Mon Sep 17 00:00:00 2001 From: Shachar Pashchur Date: Tue, 29 Nov 2022 18:26:30 +0200 Subject: [PATCH 4/7] Add redis logo image --- README.md | 3 ++- docs/logo-redis.png | Bin 0 -> 8388 bytes 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 docs/logo-redis.png diff --git a/README.md b/README.md index d26619d8..c32d70d6 100644 --- a/README.md +++ b/README.md @@ -81,5 +81,6 @@ json.Set(key, "$", new Person() { Age = 35, Name = "Alice" }); NRedisStack is developed and maintained by [Redis Inc](https://redis.com). It can be found [here]( https://github.com/redis/NRedisStack), or downloaded from [NuGet](https://www.nuget.org/packages/NRedisStack). -[![Redis](./docs/logo-redis.png)](https://www.redis.com) +--- +[![Redis](./docs/logo-redis.png)](https://www.redis.com) \ No newline at end of file diff --git a/docs/logo-redis.png b/docs/logo-redis.png new file mode 100644 index 0000000000000000000000000000000000000000..45b4a3f284f3d10b558c2f77b75cd11739a117f7 GIT binary patch literal 8388 zcmV;#AUofQP){*UUUW>8NR9&-s{{|NFepXVdQPu3*ZO&7|9e z5FZdibkiZZB81rJy>RgoKR$+GT)`q;a8S~5VJT~)ES1c35z(9 z&7{XjxX&bfsTCo_6pr2t7uU31Aj2?B2^w0&vzat3Z7JSe22OFF#C+DkYcmYPG@giO zGwB`@?y-oj5*_5pI-g{B3&SuvX$TR|X42hcZ9}+EJHDJH67*Siw=fKol)4u2Y$n|= zgcvvIE=fY3f}ya^mp!{ShGA-ix)X7-y2nVoZMjR5!og66VPa7?B2H<6V{x)e+8=#f zq&hpr&81(8og3H9TwrvjNz4~rUkJl6{!`N;PC-iPE{Sb*r#d>t$(Mc}{Q2guej%>E zd|s@-`Wxlf!D4Xikxz@w)jtHUk&ql*Eo_}L3{#1k6miPw)*7U|>&ssecmCr)?f-w_ z%G+Y?$1~#k%d-`&a|n0)>BmL;qkk(>9UZ~nfw`Bdd|0~}9%30l)C&`6;=bWm@FpS?K9tu+8IA!{L zou54;?)&Dq%lN zj{-zK_qiu*UosaGF-!x~?8~h?s-!$XYv0Gj<{w{=E#mN@I{>bwr*UL6=_Rtxr(9eJ z!!Y)7F5*d219i}R;{L$5-TkG}*y0@qzIBIbiU{TO{5;1kh;LtF11939R z?85w9FA0z-9hSO*1$&4C8OPN_JXBAs-wXUapcP0i$Q2mW156 zi2KmL1eSOAm!1@Dk9<1#|CST?YjK^ZaC`N2aqZ>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k! zu)K8+QiipCd4pXh3{&qIZFB<58ONm?TUv{2sy8tH~z3U(_F0<%emA219P z6D!@SV4Wj<4TtWW^I8jp;=Uo?b>=de=Bf7#;|7TMWt(TV6$tgEB2-dkR%I+aahaSO zUCr`*O@?sq#&s40K9LzhVyG*=oQUCml;9>p-sL7H}V zcg0L!Z#VTKa9VL^YIdfq2(>lv*+hP~M_DF067QNUQD&HWBM@=POkeK+iMi8>)F!$N zO5l1hc$-Zxf@rwf@F7ZXoh2iE~dySrwXSK*o6S#$RS>B$w zOa!@2CPr7YHPL8^VH%B+A}%2@AFI;8*9y7=p_0JTT`$Dyb1pMubXndwKZF}uHXan_ zOp|zf-RX~E8l8$FE}7};?IAHAkJua77^VWDvd?*bYe(GL-YHp{4vQOp`>vLhR;yd~ z?#B5YH=@eZ^phzTZ-%K2B8j+!0-z%$8nQdVR3J1AEMlFRC1Dcu?$%9?tZw#qGfa)4 zB;sLwaxA0!s> zFf)Cm4CMcV0jw zT`fAZT09YNxJ;(V@@AI_!!!WaL|j6FP-&ez&pAg{3y!#cbB~%)O>v4K!!#b&MO+ff zIrkzEDu+Fzkf)lU%XYdR6z5En)yF7)Bd)BjOSYgietE+^0Y&`@0#2(N5ioxP)9SvNf(tR|^jsW*Ej8b%h|RJpcdz zYDq*vR4d|P9Oazzpkan#jMESzF0tflVew`d#u^PJ;u1qyEiB#)!&s*wMLbNxk#d|S z$S{mk8eYUDG*S+NK2Sx_ks^p7FdSFpN Date: Wed, 30 Nov 2022 12:17:24 +0200 Subject: [PATCH 5/7] Add Search Example --- README.md | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c32d70d6..f564a98c 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,8 @@ IJsonCommands json = db.JSON(); ITimeSeriesCommands ts = db.TS(); ``` Then, that variable will allow you to call all the commands of that module. -## Basic Example +## Basic Examples +### Simple Json Set Example Set a json object to Redis: ```csharp ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); @@ -73,7 +74,45 @@ IJsonCommands json = db.JSON(); var key = "myKey"; json.Set(key, "$", new Person() { Age = 35, Name = "Alice" }); ``` +### Index & Search Example +setup: +```csharp +using NRedisStack; +... +IDatabase db = redisFixture.Redis.GetDatabase(); +ISearchCommands ft = db.FT(); +IJsonCommands json = db.JSON(); +``` +Create an index with fields and weights: +```csharp +// FT.CREATE myIdx ON HASH PREFIX 1 doc: SCHEMA title TEXT WEIGHT 5.0 body TEXT url TEXT +ft.Create("myIndex", new FTCreateParams().On(IndexDataType.Hash) + .Prefix("doc:"), + new Schema().AddTextField("title", 5.0) + .AddTextField("body") + .AddTextField("url")); +``` +After you create the index, any new hash documents with the doc: prefix are automatically indexed upon creation. + + +Use the HSET command to create a new hash document and add it to the index: +```csharp +// HSET doc:1 title "hello world" body "lorem ipsum" url "http://redis.io" +db.HashSet("doc:1", new HashEntry[] { new("title", "hello world"), + new("body", "lorem ipsum"), + new("url", "http://redis.io") }); +``` +Search the index for documents that contain "hello world": +```csharp +// FT.SEARCH myIndex "hello world" LIMIT 0 10 +ft.Search("myIndex", new Query("hello world").Limit(0, 10)); +``` +Drop the index +```csharp +// FT.DROPINDEX myIndex +ft.DropIndex("myIndex"); +``` ------ ### Author From 9accbb11d1b5a696006fe9196c451a834f489a71 Mon Sep 17 00:00:00 2001 From: Shachar Pashchur Date: Thu, 1 Dec 2022 17:01:11 +0200 Subject: [PATCH 6/7] Fixes after review --- README.md | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f564a98c..53c77c26 100644 --- a/README.md +++ b/README.md @@ -18,9 +18,9 @@ The complete documentation for Redis module commands can be found at the [Redis ### Redis OSS commands You can use Redis OSS commands in the same way as you use them in [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis). -### Stack Commands +### Stack commands Each module has a command class with its own commands. -The supported modules are: [Search](https://redis.io/commands/?group=search), [Json](https://redis.io/commands/?group=json), [Graph](https://redis.io/commands/?group=graph), [TimeSeries](https://redis.io/commands/?group=timeseries), [Bloom Filter](https://redis.io/commands/?group=bf), [Cuckoo Filter](https://redis.io/commands/?group=cf), [T-Digest](https://redis.io/commands/?group=tdigest), [Count-min Sketch](https://redis.io/commands/?group=cms) and [Top-K](https://redis.io/commands/?group=topk). +The supported modules are [Search](https://redis.io/commands/?group=search), [JSON](https://redis.io/commands/?group=json), [Graph](https://redis.io/commands/?group=graph), [TimeSeries](https://redis.io/commands/?group=timeseries), [Bloom Filter](https://redis.io/commands/?group=bf), [Cuckoo Filter](https://redis.io/commands/?group=cf), [T-Digest](https://redis.io/commands/?group=tdigest), [Count-min Sketch](https://redis.io/commands/?group=cms), and [Top-K](https://redis.io/commands/?group=topk). # Usage @@ -36,13 +36,13 @@ dotnet add package NRedisStack ### Starting Redis -Before writing any code you'll need a Redis instance with the appropriate Redis modules! The quickest way to get this is with Docker: +Before writing any code, you'll need a Redis instance with the appropriate Redis modules. The quickest way to get this is with Docker: ```sh docker run -p 6379:6379 --name redis-stack redis/redis-stack:latest ``` -This launches the [redis-stack](https://redis.io/docs/stack/) an extension of Redis that adds all manner of modern data structures to Redis. You'll also notice that if you open up http://localhost:8001 you'll have access to the redis-insight GUI, a GUI you can use to visualize and work with your data in Redis. +This launches [Redis Stack](https://redis.io/docs/stack/), an extension of Redis that adds modern data structures to Redis. Now, you need to connect to Redis, exactly the same way you do it in [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis): ```csharp @@ -63,8 +63,8 @@ IJsonCommands json = db.JSON(); ITimeSeriesCommands ts = db.TS(); ``` Then, that variable will allow you to call all the commands of that module. -## Basic Examples -### Simple Json Set Example +## Examples +### Set JSON object to Redis Set a json object to Redis: ```csharp ConnectionMultiplexer redis = ConnectionMultiplexer.Connect("localhost"); @@ -74,8 +74,10 @@ IJsonCommands json = db.JSON(); var key = "myKey"; json.Set(key, "$", new Person() { Age = 35, Name = "Alice" }); ``` -### Index & Search Example -setup: +### Index and search +We will see an example that shows how you can create an index, add a document to it and search it using NRedisStack. + +Setup: ```csharp using NRedisStack; ... @@ -96,7 +98,7 @@ ft.Create("myIndex", new FTCreateParams().On(IndexDataType.Hash) After you create the index, any new hash documents with the doc: prefix are automatically indexed upon creation. -Use the HSET command to create a new hash document and add it to the index: +To create a new hash document and add it to the index, use the HSET command: ```csharp // HSET doc:1 title "hello world" body "lorem ipsum" url "http://redis.io" db.HashSet("doc:1", new HashEntry[] { new("title", "hello world"), @@ -108,7 +110,7 @@ Search the index for documents that contain "hello world": // FT.SEARCH myIndex "hello world" LIMIT 0 10 ft.Search("myIndex", new Query("hello world").Limit(0, 10)); ``` -Drop the index +Drop the index: ```csharp // FT.DROPINDEX myIndex ft.DropIndex("myIndex"); From 47cd7f84d64e40dca7d6f77aed38cd51041503ab Mon Sep 17 00:00:00 2001 From: Shachar Pashchur Date: Thu, 1 Dec 2022 17:05:40 +0200 Subject: [PATCH 7/7] Add words to wordlist --- .github/wordlist.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/wordlist.txt b/.github/wordlist.txt index e06e6f38..cea8e35b 100644 --- a/.github/wordlist.txt +++ b/.github/wordlist.txt @@ -8,4 +8,7 @@ OSS Json json TimeSeries -NuGet \ No newline at end of file +NuGet +cli +dotnet +HSET \ No newline at end of file