@@ -14,7 +14,7 @@ type: integration
1414
1515## SearchIndex
1616
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) `
1818
1919A search index class for interacting with Redis as a vector database.
2020
@@ -26,8 +26,7 @@ settings and field configurations.
2626from redisvl.index import SearchIndex
2727
2828# 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" )
3130
3231# create the index
3332index.create(overwrite = True )
@@ -49,7 +48,7 @@ kwargs.
4948 instantiated redis client.
5049 * ** redis_url** (* Optional* * [ * * str* * ] * ) – The URL of the Redis server to
5150 connect to.
52- * ** connection_args ** (* Dict* * [ * * str* * ,* * Any* * ] * * ,* * optional* ) – Redis client connection
51+ * ** connection_kwargs ** (* Dict* * [ * * str* * ,* * Any* * ] * * ,* * optional* ) – Redis client connection
5352 args.
5453
5554#### ` aggregate(*args, **kwargs) `
@@ -85,13 +84,13 @@ extra options specific to the Redis connection.
8584
8685* ** Parameters:**
8786 ** 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.
9088* ** Raises:**
9189 * ** redis.exceptions.ConnectionError** – If the connection to the Redis
9290 server fails.
9391 * ** ValueError** – If the Redis URL is not provided nor accessible
9492 through the REDIS_URL environment variable.
93+ * ** ModuleNotFoundError** – If required Redis modules are not installed.
9594
9695``` python
9796index.connect(redis_url = " redis://localhost:6379" )
@@ -158,6 +157,16 @@ Check if the index exists in Redis.
158157* ** Return type:**
159158 bool
160159
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+
161170#### ` fetch(id) `
162171
163172Fetch an object from Redis by id.
@@ -210,6 +219,9 @@ Initialize from an existing search index in Redis by index name.
210219 instantiated redis client.
211220 * ** redis_url** (* Optional* * [ * * str* * ] * ) – The URL of the Redis server to
212221 connect to.
222+ * ** Raises:**
223+ * ** ValueError** – If redis_url or redis_client is not provided.
224+ * ** RedisModuleVersionError** – If required Redis modules are not installed.
213225
214226#### ` classmethod from_yaml(schema_path, **kwargs) `
215227
@@ -438,7 +450,7 @@ hash or json.
438450
439451## AsyncSearchIndex
440452
441- ### ` class AsyncSearchIndex(schema, **kwargs) `
453+ ### ` class AsyncSearchIndex(schema, *, redis_url=None, redis_client=None, connection_kwargs=None, * *kwargs) `
442454
443455A search index class for interacting with Redis as a vector database in
444456async-mode.
@@ -451,8 +463,10 @@ various settings and field configurations.
451463from redisvl.index import AsyncSearchIndex
452464
453465# 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+ )
456470
457471# create the index
458472await index.create(overwrite = True )
@@ -468,7 +482,11 @@ Initialize the RedisVL async search index with a schema.
468482
469483* ** Parameters:**
470484 * ** 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
472490 args.
473491
474492#### ` async aggregate(*args, **kwargs) `
@@ -494,27 +512,12 @@ available and in-place for future insertions or updates.
494512* ** Return type:**
495513 int
496514
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) `
501516
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_ \_ .
504518
505519* ** 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* )
518521
519522#### ` async create(overwrite=False, drop=False) `
520523
@@ -553,9 +556,9 @@ Delete the search index.
553556* ** Raises:**
554557 ** redis.exceptions.ResponseError** – If the index does not exist.
555558
556- #### ` disconnect() `
559+ #### ` async disconnect()`
557560
558- Disconnect and cleanup the underlying async redis connection .
561+ Disconnect from the Redis database .
559562
560563#### ` async drop_keys(keys) `
561564
@@ -577,6 +580,16 @@ Check if the index exists in Redis.
577580* ** Return type:**
578581 bool
579582
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+
580593#### ` async fetch(id) `
581594
582595Asynchronously etch an object from Redis by id. The id is typically
@@ -805,29 +818,13 @@ to the redis-py ft.search() method.
805818* ** Return type:**
806819 Result
807820
808- #### ` async set_client(redis_client)`
821+ #### ` set_client(redis_client) `
809822
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_ \_ .
815825
816826* ** 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* )
831828
832829#### ` property client: Redis | None `
833830
0 commit comments