Skip to content

Commit 07fab34

Browse files
author
Yuval Levy
committed
initial support for redis vector db as coded by augment
1 parent 9a1f519 commit 07fab34

File tree

8 files changed

+737
-9
lines changed

8 files changed

+737
-9
lines changed

docs/reference/alpha-vector-database.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Below are supported vector databases and implemented features:
1515
| Faiss | [ ] | [ ] | [] | [] |
1616
| SQLite | [x] | [ ] | [x] | [x] |
1717
| Qdrant | [x] | [x] | [] | [] |
18+
| Redis | [x] | [x] | [x] | [x] |
1819

1920
*Note: V2 Support means the SDK supports retrieval of features along with vector embeddings from vector similarity search.
2021

@@ -189,7 +190,7 @@ print('\n'.join([c.message.content for c in response.choices]))
189190

190191
### Configuration and Installation
191192

192-
We offer [Milvus](https://milvus.io/), [PGVector](https://github.com/pgvector/pgvector), [SQLite](https://github.com/asg017/sqlite-vec), [Elasticsearch](https://www.elastic.co) and [Qdrant](https://qdrant.tech/) as Online Store options for Vector Databases.
193+
We offer [Milvus](https://milvus.io/), [PGVector](https://github.com/pgvector/pgvector), [SQLite](https://github.com/asg017/sqlite-vec), [Elasticsearch](https://www.elastic.co), [Qdrant](https://qdrant.tech/), and [Redis](https://redis.io/) as Online Store options for Vector Databases.
193194

194195
Milvus offers a convenient local implementation for vector similarity search. To use Milvus, you can install the Feast package with the Milvus extra.
195196

@@ -209,6 +210,18 @@ pip install feast[elasticsearch]
209210
```bash
210211
pip install feast[qdrant]
211212
```
213+
214+
#### Installation with Redis
215+
216+
```bash
217+
pip install feast[redis]
218+
```
219+
220+
Note: Redis vector search requires Redis with RediSearch module. You can use:
221+
- Redis Stack (includes RediSearch)
222+
- Redis Enterprise with RediSearch module
223+
- Redis with RediSearch module installed
224+
212225
#### Installation with SQLite
213226

214227
If you are using `pyenv` to manage your Python versions, you can install the SQLite extension with the following command:

docs/reference/online-stores/redis.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,65 @@ online_store:
7979

8080
The full set of configuration options is available in [RedisOnlineStoreConfig](https://rtd.feast.dev/en/latest/#feast.infra.online_stores.redis.RedisOnlineStoreConfig).
8181

82+
## Vector Search Support
83+
84+
Redis online store supports vector similarity search through RediSearch. To enable vector search capabilities:
85+
86+
{% code title="feature_store.yaml" %}
87+
```yaml
88+
project: my_feature_repo
89+
registry: data/registry.db
90+
provider: local
91+
online_store:
92+
type: redis
93+
connection_string: "localhost:6379"
94+
vector_enabled: true
95+
vector_dim: 384
96+
vector_index_type: "FLAT" # or "HNSW"
97+
vector_distance_metric: "COSINE" # or "L2", "IP"
98+
```
99+
{% endcode %}
100+
101+
### Vector Configuration Options
102+
103+
- `vector_enabled`: Whether to enable vector search capabilities (default: False)
104+
- `vector_dim`: Vector dimension - must be specified if vector_enabled is True
105+
- `vector_index_type`: Vector index type - "FLAT" or "HNSW" (default: "FLAT")
106+
- `vector_distance_metric`: Distance metric - "COSINE", "L2", or "IP" (default: "COSINE")
107+
- `hnsw_m`: Max number of outgoing edges for HNSW index (default: 16)
108+
- `hnsw_ef_construction`: Max number of connected neighbors during HNSW graph building (default: 200)
109+
- `hnsw_ef_runtime`: Max top candidates during HNSW KNN search (default: 10)
110+
111+
### Prerequisites
112+
113+
Vector search requires Redis with RediSearch module. You can use:
114+
- Redis Stack (includes RediSearch)
115+
- Redis Enterprise with RediSearch module
116+
- Redis with RediSearch module installed
117+
118+
### Retrieving online document vectors
119+
120+
The Redis online store supports retrieving document vectors for vector similarity search:
121+
122+
{% code title="python" %}
123+
```python
124+
from feast import FeatureStore
125+
126+
feature_store = FeatureStore(repo_path="feature_store.yaml")
127+
128+
query_vector = [1.0, 2.0, 3.0, 4.0, 5.0]
129+
top_k = 5
130+
131+
# Retrieve the top k closest features to the query vector
132+
feature_values = feature_store.retrieve_online_documents_v2(
133+
features=["my_feature_view:vector_field", "my_feature_view:metadata"],
134+
query=query_vector,
135+
top_k=top_k,
136+
distance_metric="COSINE"
137+
)
138+
```
139+
{% endcode %}
140+
82141
## Functionality Matrix
83142

84143
The set of functionality supported by online stores is described in detail [here](overview.md#functionality).
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
from datetime import timedelta
2+
from feast import Entity, FeatureView, Field, FileSource
3+
from feast.types import Array, Float32, Int64, String, UnixTimestamp
4+
5+
# Define entities
6+
item = Entity(name="item_id", join_keys=["item_id"])
7+
8+
# Define data source
9+
documents_source = FileSource(
10+
name="documents_source",
11+
path="data/documents.parquet",
12+
timestamp_field="event_timestamp",
13+
)
14+
15+
# Define feature view with vector field
16+
document_embeddings = FeatureView(
17+
name="document_embeddings",
18+
entities=[item],
19+
schema=[
20+
Field(
21+
name="vector",
22+
dtype=Array(Float32),
23+
vector_index=True,
24+
vector_search_metric="COSINE",
25+
),
26+
Field(name="item_id", dtype=Int64),
27+
Field(name="content", dtype=String),
28+
Field(name="event_timestamp", dtype=UnixTimestamp),
29+
],
30+
source=documents_source,
31+
ttl=timedelta(hours=24),
32+
)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
project: redis_vector_search
2+
provider: local
3+
registry: data/registry.db
4+
online_store:
5+
type: redis
6+
connection_string: "localhost:6379"
7+
vector_enabled: true
8+
vector_dim: 384
9+
vector_index_type: "FLAT"
10+
vector_distance_metric: "COSINE"
11+
12+
offline_store:
13+
type: file
14+
15+
entity_key_serialization_version: 3
16+
17+
auth:
18+
type: no_auth

0 commit comments

Comments
 (0)