@@ -14,7 +14,7 @@ type: integration
14
14
15
15
## SearchIndex
16
16
17
- ### ` class SearchIndex(schema, redis_client=None, redis_url=None, connection_args={} , **kwargs) `
17
+ ### ` class SearchIndex(schema, redis_client=None, redis_url=None, connection_kwargs=None , **kwargs) `
18
18
19
19
A search index class for interacting with Redis as a vector database.
20
20
@@ -26,8 +26,7 @@ settings and field configurations.
26
26
from redisvl.index import SearchIndex
27
27
28
28
# initialize the index object with schema from file
29
- index = SearchIndex.from_yaml(" schemas/schema.yaml" )
30
- index.connect(redis_url = " redis://localhost:6379" )
29
+ index = SearchIndex.from_yaml(" schemas/schema.yaml" , redis_url = " redis://localhost:6379" )
31
30
32
31
# create the index
33
32
index.create(overwrite = True )
@@ -49,7 +48,7 @@ kwargs.
49
48
instantiated redis client.
50
49
* ** redis_url** (* Optional* * [ * * str* * ] * ) – The URL of the Redis server to
51
50
connect to.
52
- * ** connection_args ** (* Dict* * [ * * str* * ,* * Any* * ] * * ,* * optional* ) – Redis client connection
51
+ * ** connection_kwargs ** (* Dict* * [ * * str* * ,* * Any* * ] * * ,* * optional* ) – Redis client connection
53
52
args.
54
53
55
54
#### ` aggregate(*args, **kwargs) `
@@ -85,13 +84,13 @@ extra options specific to the Redis connection.
85
84
86
85
* ** Parameters:**
87
86
** redis_url** (* Optional* * [ * * str* * ] * * ,* * optional* ) – The URL of the Redis server to
88
- connect to. If not provided, the method defaults to using the
89
- REDIS_URL environment variable.
87
+ connect to.
90
88
* ** Raises:**
91
89
* ** redis.exceptions.ConnectionError** – If the connection to the Redis
92
90
server fails.
93
91
* ** ValueError** – If the Redis URL is not provided nor accessible
94
92
through the REDIS_URL environment variable.
93
+ * ** ModuleNotFoundError** – If required Redis modules are not installed.
95
94
96
95
``` python
97
96
index.connect(redis_url = " redis://localhost:6379" )
@@ -158,6 +157,16 @@ Check if the index exists in Redis.
158
157
* ** Return type:**
159
158
bool
160
159
160
+ #### ` expire_keys(keys, ttl) `
161
+
162
+ Set the expiration time for a specific entry or entries in Redis.
163
+
164
+ * ** Parameters:**
165
+ * ** keys** (* Union* * [ * * str* * ,* * List* * [ * * str* * ] * * ] * ) – The entry ID or IDs to set the expiration for.
166
+ * ** ttl** (* int* ) – The time-to-live in seconds.
167
+ * ** Return type:**
168
+ int | * List* [ int]
169
+
161
170
#### ` fetch(id) `
162
171
163
172
Fetch an object from Redis by id.
@@ -210,6 +219,9 @@ Initialize from an existing search index in Redis by index name.
210
219
instantiated redis client.
211
220
* ** redis_url** (* Optional* * [ * * str* * ] * ) – The URL of the Redis server to
212
221
connect to.
222
+ * ** Raises:**
223
+ * ** ValueError** – If redis_url or redis_client is not provided.
224
+ * ** RedisModuleVersionError** – If required Redis modules are not installed.
213
225
214
226
#### ` classmethod from_yaml(schema_path, **kwargs) `
215
227
@@ -438,7 +450,7 @@ hash or json.
438
450
439
451
## AsyncSearchIndex
440
452
441
- ### ` class AsyncSearchIndex(schema, **kwargs) `
453
+ ### ` class AsyncSearchIndex(schema, *, redis_url=None, redis_client=None, connection_kwargs=None, * *kwargs) `
442
454
443
455
A search index class for interacting with Redis as a vector database in
444
456
async-mode.
@@ -451,8 +463,10 @@ various settings and field configurations.
451
463
from redisvl.index import AsyncSearchIndex
452
464
453
465
# initialize the index object with schema from file
454
- index = AsyncSearchIndex.from_yaml(" schemas/schema.yaml" )
455
- await index.connect(redis_url = " redis://localhost:6379" )
466
+ index = AsyncSearchIndex.from_yaml(
467
+ " schemas/schema.yaml" ,
468
+ redis_url = " redis://localhost:6379"
469
+ )
456
470
457
471
# create the index
458
472
await index.create(overwrite = True )
@@ -468,7 +482,11 @@ Initialize the RedisVL async search index with a schema.
468
482
469
483
* ** Parameters:**
470
484
* ** schema** ([ * IndexSchema* ] ({{< relref "schema/#indexschema" >}})) – Index schema object.
471
- * ** connection_args** (* Dict* * [ * * str* * ,* * Any* * ] * * ,* * optional* ) – Redis client connection
485
+ * ** redis_url** (* Optional* * [ * * str* * ] * * ,* * optional* ) – The URL of the Redis server to
486
+ connect to.
487
+ * ** redis_client** (* Optional* * [ * * aredis.Redis* * ] * ) – An
488
+ instantiated redis client.
489
+ * ** connection_kwargs** (* Optional* * [ * * Dict* * [ * * str* * ,* * Any* * ] * * ] * ) – Redis client connection
472
490
args.
473
491
474
492
#### ` async aggregate(*args, **kwargs) `
@@ -494,27 +512,12 @@ available and in-place for future insertions or updates.
494
512
* ** Return type:**
495
513
int
496
514
497
- #### ` async connect(redis_url=None, **kwargs) `
498
-
499
- Connect to a Redis instance using the provided redis_url, falling
500
- back to the REDIS_URL environment variable (if available).
515
+ #### ` connect(redis_url=None, **kwargs) `
501
516
502
- Note: Additional keyword arguments (\*\* kwargs) can be used to provide
503
- extra options specific to the Redis connection.
517
+ [ DEPRECATED] Connect to a Redis instance. Use connection parameters in \_\_ init_ \_ .
504
518
505
519
* ** Parameters:**
506
- ** redis_url** (* Optional* * [ * * str* * ] * * ,* * optional* ) – The URL of the Redis server to
507
- connect to. If not provided, the method defaults to using the
508
- REDIS_URL environment variable.
509
- * ** Raises:**
510
- * ** redis.exceptions.ConnectionError** – If the connection to the Redis
511
- server fails.
512
- * ** ValueError** – If the Redis URL is not provided nor accessible
513
- through the REDIS_URL environment variable.
514
-
515
- ``` python
516
- index.connect(redis_url = " redis://localhost:6379" )
517
- ```
520
+ ** redis_url** (* str* * |* * None* )
518
521
519
522
#### ` async create(overwrite=False, drop=False) `
520
523
@@ -553,9 +556,9 @@ Delete the search index.
553
556
* ** Raises:**
554
557
** redis.exceptions.ResponseError** – If the index does not exist.
555
558
556
- #### ` disconnect() `
559
+ #### ` async disconnect()`
557
560
558
- Disconnect and cleanup the underlying async redis connection .
561
+ Disconnect from the Redis database .
559
562
560
563
#### ` async drop_keys(keys) `
561
564
@@ -577,6 +580,16 @@ Check if the index exists in Redis.
577
580
* ** Return type:**
578
581
bool
579
582
583
+ #### ` async expire_keys(keys, ttl) `
584
+
585
+ Set the expiration time for a specific entry or entries in Redis.
586
+
587
+ * ** Parameters:**
588
+ * ** keys** (* Union* * [ * * str* * ,* * List* * [ * * str* * ] * * ] * ) – The entry ID or IDs to set the expiration for.
589
+ * ** ttl** (* int* ) – The time-to-live in seconds.
590
+ * ** Return type:**
591
+ int | * List* [ int]
592
+
580
593
#### ` async fetch(id) `
581
594
582
595
Asynchronously etch an object from Redis by id. The id is typically
@@ -805,29 +818,13 @@ to the redis-py ft.search() method.
805
818
* ** Return type:**
806
819
Result
807
820
808
- #### ` async set_client(redis_client)`
821
+ #### ` set_client(redis_client) `
809
822
810
- Manually set the Redis client to use with the search index.
811
-
812
- This method configures the search index to use a specific
813
- Async Redis client. It is useful for cases where an external,
814
- custom-configured client is preferred instead of creating a new one.
823
+ [ DEPRECATED] Manually set the Redis client to use with the search index.
824
+ This method is deprecated; please provide connection parameters in \_\_ init_ \_ .
815
825
816
826
* ** Parameters:**
817
- ** redis_client** (* aredis.Redis* ) – An Async Redis
818
- client instance to be used for the connection.
819
- * ** Raises:**
820
- ** TypeError** – If the provided client is not valid.
821
-
822
- ``` python
823
- import redis.asyncio as aredis
824
- from redisvl.index import AsyncSearchIndex
825
-
826
- # async Redis client and index
827
- client = aredis.Redis.from_url(" redis://localhost:6379" )
828
- index = AsyncSearchIndex.from_yaml(" schemas/schema.yaml" )
829
- await index.set_client(client)
830
- ```
827
+ ** redis_client** (* Redis* * |* * Redis* )
831
828
832
829
#### ` property client: Redis | None `
833
830
0 commit comments