Skip to content

Commit 28c3c3e

Browse files
Merge branch 'main' into DOC-5109-csharp-hash-search-example
2 parents 6d3b3ed + fc4eb4a commit 28c3c3e

File tree

233 files changed

+2711
-845
lines changed

Some content is hidden

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

233 files changed

+2711
-845
lines changed

config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ rdi_redis_gears_version = "1.2.6"
5555
rdi_debezium_server_version = "2.3.0.Final"
5656
rdi_db_types = "cassandra|mysql|oracle|postgresql|sqlserver"
5757
rdi_cli_latest = "latest"
58-
rdi_current_version = "v1.6.5"
58+
rdi_current_version = "v1.6.6"
5959

6060
[params.clientsConfig]
6161
"Python"={quickstartSlug="redis-py"}

content/commands/info/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ It won't be included when `INFO` or `INFO ALL` are called, and it is returned on
602602

603603
| Redis<br />Enterprise | Redis<br />Cloud | <span style="min-width: 9em; display: table-cell">Notes</span> |
604604
|:----------------------|:-----------------|:------|
605-
| <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | In Redis Enterprise, `INFO` returns a different set of fields than Redis Community Edition.<br />Not supported for [scripts]({{<relref "/develop/interact/programmability">}}). |
605+
| <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | <span title="Supported">&#x2705; Standard</span><br /><span title="Supported"><nobr>&#x2705; Active-Active</nobr></span> | In Redis Enterprise, `INFO` returns a different set of fields than Redis Open Source.<br />Not supported for [scripts]({{<relref "/develop/interact/programmability">}}). |
606606

607607
Note: key memory usage is different on Redis Software or Redis Cloud active-active databases than on non-active-active databases. This is because memory usage includes some amount of CRDB overhead.
608608

content/commands/module-load/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ unmodified to the module.
4949
configuration directive in `redis.conf`.
5050

5151
{{< note >}}
52-
As of Redis CE v8.0.0, loading a module using the Redis CLI with configuration parameters is deprecated.
52+
As of Redis 8 in Redis Open Source, loading a module using the Redis CLI with configuration parameters is deprecated.
5353
{{< /note >}}

content/develop/ai/index.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ This page organized into a few sections depending on what you’re trying to do:
3434
1. [**Search with vectors**]({{< relref "develop/interact/search-and-query/advanced-concepts/vectors#search-with-vectors" >}}): Redis supports several advanced querying strategies with vector fields including k-nearest neighbor ([KNN]({{< relref "develop/interact/search-and-query/advanced-concepts/vectors#knn-vector-search" >}})), [vector range queries]({{< relref "develop/interact/search-and-query/advanced-concepts/vectors#vector-range-queries" >}}), and [metadata filters]({{< relref "develop/interact/search-and-query/advanced-concepts/vectors#filters" >}}).
3535
1. [**Configure vector queries at runtime**]({{< relref "develop/interact/search-and-query/advanced-concepts/vectors#runtime-query-parameters" >}}). Select the best filter mode to optimize query execution.
3636

37+
#### Learn how to index and query vector embeddings
38+
* [redis-py (Python)]({{< relref "/develop/clients/redis-py/vecsearch" >}})
39+
* [NRedisStack (C#/.NET)]({{< relref "/develop/clients/dotnet/vecsearch" >}})
40+
* [node-redis (JavaScript)]({{< relref "/develop/clients/nodejs/vecsearch" >}})
41+
* [Jedis (Java)]({{< relref "/develop/clients/jedis/vecsearch" >}})
42+
* [go-redis (Go)]({{< relref "/develop/clients/go/vecsearch" >}})
43+
3744
## Concepts
3845

3946
Learn to perform vector search and use gateways and semantic caching in your AI/ML projects.
@@ -71,6 +78,7 @@ Retrieval Augmented Generation (aka RAG) is a technique to enhance the ability o
7178

7279
#### Agents
7380
AI agents can act autonomously to plan and execute tasks for the user.
81+
* [Redis Notebooks for LangGraph](https://github.com/redis-developer/langgraph-redis/tree/main/examples)
7482
* [Notebook to get started with LangGraph and agents](https://colab.research.google.com/github/redis-developer/redis-ai-resources/blob/main/python-recipes/agents/00_langgraph_redis_agentic_rag.ipynb)
7583
* [Build a collaborative movie recommendation system using Redis for data storage, CrewAI for agent-based task execution, and LangGraph for workflow management.](https://colab.research.google.com/github/redis-developer/redis-ai-resources/blob/main/python-recipes/agents/01_crewai_langgraph_redis.ipynb)
7684
* [Full-Featured Agent Architecture](https://github.com/redis-developer/redis-ai-resources/blob/main/python-recipes/agents/02_full_featured_agent.ipynb)
@@ -119,6 +127,7 @@ Need a deeper-dive through different use cases and topics?
119127

120128
## Ecosystem integrations
121129

130+
* [LangGraph & Redis: Build smarter AI agents with memory & persistence](https://redis.io/blog/langgraph-redis-build-smarter-ai-agents-with-memory-persistence/)
122131
* [Amazon Bedrock setup guide]({{< relref "/integrate/amazon-bedrock/set-up-redis" >}})
123132
* [LangChain Redis Package: Smarter AI apps with advanced vector storage and faster caching](https://redis.io/blog/langchain-redis-partner-package/)
124133
* [LlamaIndex integration for Redis as a vector store](https://gpt-index.readthedocs.io/en/latest/examples/vector_stores/RedisIndexDemo.html)

content/develop/clients/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ Redis does not document directly:
5757
## Requirements
5858

5959
You will need access to a Redis server to use these libraries.
60-
You can experiment with a local installation of Redis Community Edition
61-
(see [Install Redis Community Edition]({{< relref "/operate/oss_and_stack/install/install-stack/" >}})) or with a free trial of [Redis Cloud]({{< relref "/operate/rc" >}}).
60+
You can experiment with a local installation of Redis Open Source
61+
(see [Install Redis Open Source]({{< relref "/operate/oss_and_stack/install/install-stack/" >}})) or with a free trial of [Redis Cloud]({{< relref "/operate/rc" >}}).
6262
To interact with a Redis server without writing code, use the
6363
[Redis CLI]({{< relref "/develop/tools/cli" >}}) and
6464
[Redis Insight]({{< relref "/develop/tools/insight" >}}) tools.

content/develop/clients/dotnet/_index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ weight: 3
2020
The sections below explain how to install `NRedisStack` and connect your application
2121
to a Redis database.
2222

23-
`NRedisStack` requires a running [Redis Community Edition]({{< relref "/operate/oss_and_stack/install/install-stack/" >}}) server. See [Getting started]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis installation instructions.
23+
`NRedisStack` requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.
2424

2525
You can also access Redis with an object-mapping client interface. See
2626
[Redis OM for .NET]({{< relref "/integrate/redisom-for-net" >}})
@@ -70,9 +70,9 @@ Console.WriteLine(String.Join("; ", hashFields));
7070
// Prints:
7171
// name: John; surname: Smith; company: Redis; age: 29
7272
```
73-
## Redis Community Edition modules
73+
## Redis Open Source modules
7474

75-
To access Redis Community Edition capabilities, use the appropriate interface like this:
75+
To access Redis Open Source capabilities, use the appropriate interface like this:
7676

7777
```
7878
IBloomCommands bf = db.BF();

content/develop/clients/dotnet/vecsearch.md

Lines changed: 156 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ In the example below, we use [Microsoft.ML](https://dotnet.microsoft.com/en-us/a
3232
to generate the vector embeddings to store and index with Redis Query Engine.
3333
We also show how to adapt the code to use
3434
[Azure OpenAI](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/embeddings?tabs=csharp)
35-
for the embeddings.
35+
for the embeddings. The code is first demonstrated for hash documents with a
36+
separate section to explain the
37+
[differences with JSON documents](#differences-with-json-documents).
3638

3739
## Initialize
3840

@@ -89,7 +91,6 @@ using Azure;
8991
using Azure.AI.OpenAI;
9092
```
9193

92-
9394
## Define a function to obtain the embedding model
9495

9596
{{< note >}}Ignore this step if you are using an Azure OpenAI
@@ -154,7 +155,9 @@ array as a `byte` string. To simplify this, we declare a
154155
then encodes the returned `float` array as a `byte` string. If you are
155156
storing your documents as JSON objects instead of hashes, then you should
156157
use the `float` array for the embedding directly, without first converting
157-
it to a `byte` string.
158+
it to a `byte` string (see [Differences with JSON documents](#differences-with-json-documents)
159+
below).
160+
158161

159162
```csharp
160163
static byte[] GetEmbedding(
@@ -414,6 +417,156 @@ As you would expect, the result for `doc:1` with the content text
414417
is the result that is most similar in meaning to the query text
415418
*"That is a happy person"*.
416419

420+
## Differences with JSON documents
421+
422+
Indexing JSON documents is similar to hash indexing, but there are some
423+
important differences. JSON allows much richer data modeling with nested fields, so
424+
you must supply a [path]({{< relref "/develop/data-types/json/path" >}}) in the schema
425+
to identify each field you want to index. However, you can declare a short alias for each
426+
of these paths to avoid typing it in full for
427+
every query. Also, you must specify `IndexType.JSON` with the `On()` option when you
428+
create the index.
429+
430+
The code below shows these differences, but the index is otherwise very similar to
431+
the one created previously for hashes:
432+
433+
```cs
434+
var jsonSchema = new Schema()
435+
.AddTextField(new FieldName("$.content", "content"))
436+
.AddTagField(new FieldName("$.genre", "genre"))
437+
.AddVectorField(
438+
new FieldName("$.embedding", "embedding"),
439+
VectorField.VectorAlgo.HNSW,
440+
new Dictionary<string, object>()
441+
{
442+
["TYPE"] = "FLOAT32",
443+
["DIM"] = "150",
444+
["DISTANCE_METRIC"] = "L2"
445+
}
446+
);
447+
448+
449+
db.FT().Create(
450+
"vector_json_idx",
451+
new FTCreateParams()
452+
.On(IndexDataType.JSON)
453+
.Prefix("jdoc:"),
454+
jsonSchema
455+
);
456+
```
457+
458+
An important difference with JSON indexing is that the vectors are
459+
specified using arrays of `float` instead of binary strings. This requires a modification
460+
to the `GetEmbedding()` function declared in
461+
[Define a function to generate an embedding](#define-a-function-to-generate-an-embedding)
462+
above:
463+
464+
```cs
465+
static float[] GetFloatEmbedding(
466+
PredictionEngine<TextData, TransformedTextData> model, string sentence
467+
)
468+
{
469+
// Call the prediction API to convert the text into embedding vector.
470+
var data = new TextData()
471+
{
472+
Text = sentence
473+
};
474+
475+
var prediction = model.Predict(data);
476+
477+
float[] floatArray = Array.ConvertAll(prediction.Features, x => (float)x);
478+
return floatArray;
479+
}
480+
```
481+
482+
You should make a similar modification to the `GetEmbeddingFromAzure()` function
483+
if you are using Azure OpenAI with JSON.
484+
485+
Use [`JSON().set()`]({{< relref "/commands/json.set" >}}) to add the data
486+
instead of [`HashSet()`]({{< relref "/commands/hset" >}}):
487+
488+
```cs
489+
var jSentence1 = "That is a very happy person";
490+
491+
var jdoc1 = new {
492+
content = jSentence1,
493+
genre = "persons",
494+
embedding = GetFloatEmbedding(predEngine, jSentence1),
495+
};
496+
497+
db.JSON().Set("jdoc:1", "$", jdoc1);
498+
499+
var jSentence2 = "That is a happy dog";
500+
501+
var jdoc2 = new {
502+
content = jSentence2,
503+
genre = "pets",
504+
embedding = GetFloatEmbedding(predEngine, jSentence2),
505+
};
506+
507+
db.JSON().Set("jdoc:2", "$", jdoc2);
508+
509+
var jSentence3 = "Today is a sunny day";
510+
511+
var jdoc3 = new {
512+
content = jSentence3,
513+
genre = "weather",
514+
embedding = GetFloatEmbedding(predEngine, jSentence3),
515+
};
516+
517+
db.JSON().Set("jdoc:3", "$", jdoc3);
518+
```
519+
520+
The query is almost identical to the one for the hash documents. This
521+
demonstrates how the right choice of aliases for the JSON paths can
522+
save you having to write complex queries. The only significant difference is
523+
that the `FieldName` objects created for the `ReturnFields()` option must
524+
include the JSON path for the field.
525+
526+
An important thing to notice
527+
is that the vector parameter for the query is still specified as a
528+
binary string (using the `GetEmbedding()` method), even though the data for
529+
the `embedding` field of the JSON was specified as a `float` array.
530+
531+
```cs
532+
var jRes = db.FT().Search("vector_json_idx",
533+
new Query("*=>[KNN 3 @embedding $query_vec AS score]")
534+
.AddParam("query_vec", GetEmbedding(predEngine, "That is a happy person"))
535+
.ReturnFields(
536+
new FieldName("$.content", "content"),
537+
new FieldName("$.score", "score")
538+
)
539+
.SetSortBy("score")
540+
.Dialect(2));
541+
542+
foreach (var doc in jRes.Documents) {
543+
var props = doc.GetProperties();
544+
var propText = string.Join(
545+
", ",
546+
props.Select(p => $"{p.Key}: '{p.Value}'")
547+
);
548+
549+
Console.WriteLine(
550+
$"ID: {doc.Id}, Properties: [\n {propText}\n]"
551+
);
552+
}
553+
```
554+
555+
Apart from the `jdoc:` prefixes for the keys, the result from the JSON
556+
query is the same as for hash:
557+
558+
```
559+
ID: jdoc:1, Properties: [
560+
score: '4.30777168274', content: 'That is a very happy person'
561+
]
562+
ID: jdoc:2, Properties: [
563+
score: '25.9752807617', content: 'That is a happy dog'
564+
]
565+
ID: jdoc:3, Properties: [
566+
score: '68.8638000488', content: 'Today is a sunny day'
567+
]
568+
```
569+
417570
## Learn more
418571

419572
See

content/develop/clients/go/_index.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ weight: 7
1919
[`go-redis`](https://github.com/redis/go-redis) is the [Go](https://go.dev/) client for Redis.
2020
The sections below explain how to install `go-redis` and connect your application to a Redis database.
2121

22-
`go-redis` requires a running [Redis Community Edition]({{< relref "/operate/oss_and_stack/install/install-stack/" >}}) server.
23-
See [Getting started]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis installation
24-
instructions.
22+
`go-redis` requires a running Redis server. See [here]({{< relref "/operate/oss_and_stack/install/" >}}) for Redis Open Source installation instructions.
2523

2624
## Install
2725

0 commit comments

Comments
 (0)