Skip to content

Commit 7c26d0f

Browse files
Merge branch 'master' into DOC-4560-trans-pipe-examples
2 parents 7ba27e6 + 410ddd6 commit 7c26d0f

File tree

11 files changed

+365
-54
lines changed

11 files changed

+365
-54
lines changed

.github/workflows/integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
max-parallel: 15
3838
fail-fast: false
3939
matrix:
40-
redis-version: [ '8.0-M04-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.6', '6.2.16']
40+
redis-version: [ '8.0-RC2-pre', '${{ needs.redis_version.outputs.CURRENT }}', '7.2.6', '6.2.16']
4141
dotnet-version: ['6.0', '7.0', '8.0']
4242
env:
4343
ACTIONS_ALLOW_UNSECURE_COMMANDS: true

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ Each module has a command class with its own commands.
4040

4141
The supported modules are [Search](https://redis.io/commands/?group=search), [JSON](https://redis.io/commands/?group=json), [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).
4242

43-
**Note:** RedisGraph support has been deprecated starting from Redis Stack version 7.2. For more information, please refer to [this blog post](https://redis.com/blog/redisgraph-eol/).
44-
**IMPORTANT:** NRedisStack will end the support for Graph functionalities with version 0.13.x
43+
**Note:** RedisGraph support has been deprecated starting from Redis Stack version 7.2. For more information, please refer to [this blog post](https://redis.com/blog/redisgraph-eol/).<br>
44+
**IMPORTANT:** NRedisStack will end the support for Graph functionalities with version 0.13.x<br>
45+
**IMPORTANT:** Starting from version **1.0.0-beta1**, by default, the client now overrides the [server-side dialect](https://redis.io/docs/latest/develop/interact/search-and-query/advanced-concepts/dialects/) with version 2, automatically appending `DIALECT 2` to commands like **FT.AGGREGATE** and **FT.SEARCH**. Be aware that the query dialect may impact the results returned. If needed, you can revert to a different dialect version by configuring the client accordingly. Please see [release notes](https://github.com/redis/NRedisStack/releases/tag/v1.0.0-beta1).
4546

4647
# Usage
4748

src/NRedisStack/NRedisStack.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
<Owners>Redis OSS</Owners>
1111
<Description>.Net Client for Redis Stack</Description>
1212
<PackageReadmeFile>README.md</PackageReadmeFile>
13-
<Version>0.13.1</Version>
14-
<ReleaseVersion>0.13.1</ReleaseVersion>
15-
<PackageVersion>0.13.1</PackageVersion>
13+
<Version>1.0.0-beta1</Version>
14+
<ReleaseVersion>1.0.0-beta1</ReleaseVersion>
15+
<PackageVersion>1.0.0-beta1</PackageVersion>
1616
</PropertyGroup>
1717

1818
<ItemGroup>

src/NRedisStack/Pipeline.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class Pipeline
66
{
77
public Pipeline(IDatabase db)
88
{
9+
db.SetInfoInPipeline();
910
_batch = db.CreateBatch();
1011
}
1112

src/NRedisStack/Search/Schema.cs

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,10 @@ internal override void AddFieldTypeArgs(List<object> args)
9797
AddPhonetic(args);
9898
AddWeight(args);
9999
if (WithSuffixTrie) args.Add(SearchArgs.WITHSUFFIXTRIE);
100-
if (Sortable) args.Add(FieldOptions.SORTABLE);
101100
if (Unf) args.Add(SearchArgs.UNF);
102101
if (MissingIndex) args.Add(FieldOptions.INDEXMISSING);
103102
if (EmptyIndex) args.Add(FieldOptions.INDEXEMPTY);
104-
103+
if (Sortable) args.Add(FieldOptions.SORTABLE);
105104
}
106105

107106
private void AddWeight(List<object> args)
@@ -165,10 +164,10 @@ internal override void AddFieldTypeArgs(List<object> args)
165164
args.Add(Separator);
166165
}
167166
if (CaseSensitive) args.Add(SearchArgs.CASESENSITIVE);
168-
if (Sortable) args.Add(FieldOptions.SORTABLE);
169167
if (Unf) args.Add(SearchArgs.UNF);
170168
if (MissingIndex) args.Add(FieldOptions.INDEXMISSING);
171169
if (EmptyIndex) args.Add(FieldOptions.INDEXEMPTY);
170+
if (Sortable) args.Add(FieldOptions.SORTABLE);
172171
}
173172
}
174173

@@ -192,10 +191,9 @@ internal GeoField(string name, bool sortable = false, bool noIndex = false, bool
192191
internal override void AddFieldTypeArgs(List<object> args)
193192
{
194193
if (NoIndex) args.Add(SearchArgs.NOINDEX);
195-
if (Sortable) args.Add(FieldOptions.SORTABLE);
196194
if (MissingIndex) args.Add(FieldOptions.INDEXMISSING);
195+
if (Sortable) args.Add(FieldOptions.SORTABLE);
197196
}
198-
199197
}
200198

201199
public class GeoShapeField : Field
@@ -252,10 +250,9 @@ internal NumericField(string name, bool sortable = false, bool noIndex = false,
252250
internal override void AddFieldTypeArgs(List<object> args)
253251
{
254252
if (NoIndex) args.Add(SearchArgs.NOINDEX);
255-
if (Sortable) args.Add(FieldOptions.SORTABLE);
256253
if (MissingIndex) args.Add(FieldOptions.INDEXMISSING);
254+
if (Sortable) args.Add(FieldOptions.SORTABLE);
257255
}
258-
259256
}
260257

261258
public class VectorField : Field
@@ -322,6 +319,10 @@ public Schema AddField(Field field)
322319
/// <param name="unf">Set this to true to prevent the indexer from sorting on the normalized form.
323320
/// Normalied form is the field sent to lower case with all diaretics removed</param>
324321
/// <param name="withSuffixTrie">Keeps a suffix trie with all terms which match the suffix.</param>
322+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
323+
/// Note the difference between a field with an empty value and a document with a missing value.
324+
/// By default, missing values are not indexed.</param>
325+
/// <param name="emptyIndex"> allows you to index and search for empty strings. By default, empty strings are not indexed.</param>
325326
/// <returns>The <see cref="Schema"/> object.</returns>
326327
public Schema AddTextField(string name, double weight = 1.0, bool sortable = false, bool unf = false, bool noStem = false,
327328
string? phonetic = null, bool noIndex = false, bool withSuffixTrie = false, bool missingIndex = false, bool emptyIndex = false)
@@ -342,6 +343,10 @@ public Schema AddTextField(string name, double weight = 1.0, bool sortable = fal
342343
/// <param name="unf">Set this to true to prevent the indexer from sorting on the normalized form.
343344
/// Normalied form is the field sent to lower case with all diaretics removed</param>
344345
/// <param name="withSuffixTrie">Keeps a suffix trie with all terms which match the suffix.</param>
346+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
347+
/// Note the difference between a field with an empty value and a document with a missing value.
348+
/// By default, missing values are not indexed.</param>
349+
/// <param name="emptyIndex"> allows you to index and search for empty strings. By default, empty strings are not indexed.</param>
345350
/// <returns>The <see cref="Schema"/> object.</returns>
346351
public Schema AddTextField(FieldName name, double weight = 1.0, bool sortable = false, bool unf = false, bool noStem = false,
347352
string? phonetic = null, bool noIndex = false, bool withSuffixTrie = false, bool missingIndex = false, bool emptyIndex = false)
@@ -355,6 +360,9 @@ public Schema AddTextField(FieldName name, double weight = 1.0, bool sortable =
355360
/// </summary>
356361
/// <param name="name">The field's name.</param>
357362
/// <param name="system">The coordinate system to use.</param>
363+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
364+
/// Note the difference between a field with an empty value and a document with a missing value.
365+
/// By default, missing values are not indexed.</param>
358366
/// <returns>The <see cref="Schema"/> object.</returns>
359367
public Schema AddGeoShapeField(string name, CoordinateSystem system, bool missingIndex = false)
360368
{
@@ -367,6 +375,9 @@ public Schema AddGeoShapeField(string name, CoordinateSystem system, bool missin
367375
/// </summary>
368376
/// <param name="name">The field's name.</param>
369377
/// <param name="system">The coordinate system to use.</param>
378+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
379+
/// Note the difference between a field with an empty value and a document with a missing value.
380+
/// By default, missing values are not indexed.</param>
370381
/// <returns>The <see cref="Schema"/> object.</returns>
371382
public Schema AddGeoShapeField(FieldName name, CoordinateSystem system, bool missingIndex = false)
372383
{
@@ -380,6 +391,9 @@ public Schema AddGeoShapeField(FieldName name, CoordinateSystem system, bool mis
380391
/// <param name="name">The field's name.</param>
381392
/// <param name="sortable">If true, the text field can be sorted.</param>
382393
/// <param name="noIndex">Attributes can have the NOINDEX option, which means they will not be indexed.</param>
394+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
395+
/// Note the difference between a field with an empty value and a document with a missing value.
396+
/// By default, missing values are not indexed.</param>
383397
/// <returns>The <see cref="Schema"/> object.</returns>
384398
public Schema AddGeoField(FieldName name, bool sortable = false, bool noIndex = false, bool missingIndex = false)
385399
{
@@ -393,6 +407,9 @@ public Schema AddGeoField(FieldName name, bool sortable = false, bool noIndex =
393407
/// <param name="name">The field's name.</param>
394408
/// <param name="sortable">If true, the text field can be sorted.</param>
395409
/// <param name="noIndex">Attributes can have the NOINDEX option, which means they will not be indexed.</param>
410+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
411+
/// Note the difference between a field with an empty value and a document with a missing value.
412+
/// By default, missing values are not indexed.</param>
396413
/// <returns>The <see cref="Schema"/> object.</returns>
397414
public Schema AddGeoField(string name, bool sortable = false, bool noIndex = false, bool missingIndex = false)
398415
{
@@ -406,6 +423,9 @@ public Schema AddGeoField(string name, bool sortable = false, bool noIndex = fal
406423
/// <param name="name">The field's name.</param>
407424
/// <param name="sortable">If true, the text field can be sorted.</param>
408425
/// <param name="noIndex">Attributes can have the NOINDEX option, which means they will not be indexed.</param>
426+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
427+
/// Note the difference between a field with an empty value and a document with a missing value.
428+
/// By default, missing values are not indexed.</param>
409429
/// <returns>The <see cref="Schema"/> object.</returns>
410430
public Schema AddNumericField(FieldName name, bool sortable = false, bool noIndex = false, bool missingIndex = false)
411431
{
@@ -419,6 +439,9 @@ public Schema AddNumericField(FieldName name, bool sortable = false, bool noInde
419439
/// <param name="name">The field's name.</param>
420440
/// <param name="sortable">If true, the text field can be sorted.</param>
421441
/// <param name="noIndex">Attributes can have the NOINDEX option, which means they will not be indexed.</param>
442+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
443+
/// Note the difference between a field with an empty value and a document with a missing value.
444+
/// By default, missing values are not indexed.</param>
422445
/// <returns>The <see cref="Schema"/> object.</returns>
423446
public Schema AddNumericField(string name, bool sortable = false, bool noIndex = false, bool missingIndex = false)
424447
{
@@ -437,6 +460,10 @@ public Schema AddNumericField(string name, bool sortable = false, bool noIndex =
437460
/// <param name="caseSensitive">If true, Keeps the original letter cases of the tags.</param>
438461
/// Normalied form is the field sent to lower case with all diaretics removed</param>
439462
/// <param name="withSuffixTrie">Keeps a suffix trie with all terms which match the suffix.</param>
463+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
464+
/// Note the difference between a field with an empty value and a document with a missing value.
465+
/// By default, missing values are not indexed.</param>
466+
/// <param name="emptyIndex"> allows you to index and search for empty strings. By default, empty strings are not indexed.</param>
440467
/// <returns>The <see cref="Schema"/> object.</returns>
441468
public Schema AddTagField(FieldName name, bool sortable = false, bool unf = false,
442469
bool noIndex = false, string separator = ",",
@@ -457,6 +484,10 @@ public Schema AddTagField(FieldName name, bool sortable = false, bool unf = fals
457484
/// <param name="caseSensitive">If true, Keeps the original letter cases of the tags.</param>
458485
/// Normalied form is the field sent to lower case with all diaretics removed</param>
459486
/// <param name="withSuffixTrie">Keeps a suffix trie with all terms which match the suffix.</param>
487+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
488+
/// Note the difference between a field with an empty value and a document with a missing value.
489+
/// By default, missing values are not indexed.</param>
490+
/// <param name="emptyIndex"> allows you to index and search for empty strings. By default, empty strings are not indexed.</param>
460491
/// <returns>The <see cref="Schema"/> object.</returns>
461492
public Schema AddTagField(string name, bool sortable = false, bool unf = false,
462493
bool noIndex = false, string separator = ",",
@@ -471,7 +502,10 @@ public Schema AddTagField(string name, bool sortable = false, bool unf = false,
471502
/// </summary>
472503
/// <param name="name">The field's name.</param>
473504
/// <param name="algorithm">The vector similarity algorithm to use.</param>
474-
/// <param name="attribute">The algorithm attributes for the creation of the vector index.</param>
505+
/// <param name="attributes">The algorithm attributes for the creation of the vector index.</param>
506+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
507+
/// Note the difference between a field with an empty value and a document with a missing value.
508+
/// By default, missing values are not indexed.</param>
475509
/// <returns>The <see cref="Schema"/> object.</returns>
476510
public Schema AddVectorField(FieldName name, VectorAlgo algorithm, Dictionary<string, object>? attributes = null, bool missingIndex = false)
477511
{
@@ -484,7 +518,10 @@ public Schema AddVectorField(FieldName name, VectorAlgo algorithm, Dictionary<st
484518
/// </summary>
485519
/// <param name="name">The field's name.</param>
486520
/// <param name="algorithm">The vector similarity algorithm to use.</param>
487-
/// <param name="attribute">The algorithm attributes for the creation of the vector index.</param>
521+
/// <param name="attributes">The algorithm attributes for the creation of the vector index.</param>
522+
/// <param name="missingIndex"> search for missing values, that is, documents that do not contain a specific field.
523+
/// Note the difference between a field with an empty value and a document with a missing value.
524+
/// By default, missing values are not indexed.</param>
488525
/// <returns>The <see cref="Schema"/> object.</returns>
489526
public Schema AddVectorField(string name, VectorAlgo algorithm, Dictionary<string, object>? attributes = null, bool missingIndex = false)
490527
{

tests/Doc/HomeJsonExample.cs

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ public void run()
8686
schema
8787
);
8888
// STEP_END
89-
90-
// Tests for 'make_index' step.
9189
// REMOVE_START
9290
Assert.True(indexCreated);
9391
// REMOVE_END
@@ -98,8 +96,6 @@ public void run()
9896
bool user2Set = db.JSON().Set("user:2", "$", user2);
9997
bool user3Set = db.JSON().Set("user:3", "$", user3);
10098
// STEP_END
101-
102-
// Tests for 'add_data' step.
10399
// REMOVE_START
104100
Assert.True(user1Set);
105101
Assert.True(user2Set);
@@ -118,8 +114,6 @@ public void run()
118114
));
119115
// >>> {"name":"Paul Zamir","email":"[email protected]", ...
120116
// STEP_END
121-
122-
// Tests for 'query1' step.
123117
// REMOVE_START
124118
Assert.Equal(
125119
"{\"name\":\"Paul Zamir\",\"email\":\"[email protected]\",\"age\":35,\"city\":\"Tel Aviv\"}",
@@ -140,8 +134,6 @@ public void run()
140134
));
141135
// >>> London, Tel Aviv
142136
// STEP_END
143-
144-
// Tests for 'query2' step.
145137
// REMOVE_START
146138
Assert.Equal(
147139
"London, Tel Aviv",
@@ -166,8 +158,6 @@ public void run()
166158
// >>> London - 1
167159
// >>> Tel Aviv - 2
168160
// STEP_END
169-
170-
// Tests for 'query3' step.
171161
// REMOVE_START
172162
Assert.Equal(2, resultsList.Count);
173163

@@ -181,7 +171,70 @@ public void run()
181171
Assert.Equal(2, testItem["count"]);
182172
// REMOVE_END
183173

174+
// STEP_START make_hash_index
175+
var hashSchema = new Schema()
176+
.AddTextField("name")
177+
.AddTagField("city")
178+
.AddNumericField("age");
179+
180+
bool hashIndexCreated = db.FT().Create(
181+
"hash-idx:users",
182+
new FTCreateParams()
183+
.On(IndexDataType.HASH)
184+
.Prefix("huser:"),
185+
hashSchema
186+
);
187+
// STEP_END
188+
// REMOVE_START
189+
Assert.True(hashIndexCreated);
190+
// REMOVE_END
184191

192+
// STEP_START add_hash_data
193+
db.HashSet("huser:1", new HashEntry[] {
194+
new("name", "Paul John"),
195+
new("email", "[email protected]"),
196+
new("age", 42),
197+
new("city", "London")
198+
});
199+
200+
db.HashSet("huser:2", new HashEntry[] {
201+
new("name", "Eden Zamir"),
202+
new("email", "[email protected]"),
203+
new("age", 29),
204+
new("city", "Tel Aviv")
205+
});
206+
207+
db.HashSet("huser:3", new HashEntry[] {
208+
new("name", "Paul Zamir"),
209+
new("email", "[email protected]"),
210+
new("age", 35),
211+
new("city", "Tel Aviv")
212+
});
213+
// STEP_END
214+
215+
// STEP_START query1_hash
216+
SearchResult findPaulHashResult = db.FT().Search(
217+
"hash-idx:users",
218+
new Query("Paul @age:[30 40]")
219+
);
220+
221+
foreach (Document doc in findPaulHashResult.Documents)
222+
{
223+
Console.WriteLine(
224+
$"Name: {doc["name"]}, email: {doc["email"]}, " +
225+
$"age: {doc["age"]}, city:{doc["city"]}"
226+
);
227+
}
228+
// >>> Name: Paul Zamir, email: [email protected], age: 35, ...
229+
// STEP_END
230+
// REMOVE_START
231+
Document d = findPaulHashResult.Documents[0];
232+
Assert.Equal(
233+
"Name: Paul Zamir, email: [email protected], age: 35, city:Tel Aviv",
234+
$"Name: {d["name"]}, email: {d["email"]}, " +
235+
$"age: {d["age"]}, city:{d["city"]}"
236+
);
237+
// REMOVE_END
185238
// HIDE_START
186239
}
187240
}

0 commit comments

Comments
 (0)