docarray.array.storage.redis package#
Submodules#
- docarray.array.storage.redis.backend module
RedisConfig
RedisConfig.n_dim
RedisConfig.host
RedisConfig.port
RedisConfig.index_name
RedisConfig.list_like
RedisConfig.update_schema
RedisConfig.distance
RedisConfig.redis_config
RedisConfig.index_text
RedisConfig.tag_indices
RedisConfig.language
RedisConfig.batch_size
RedisConfig.method
RedisConfig.ef_construction
RedisConfig.m
RedisConfig.ef_runtime
RedisConfig.block_size
RedisConfig.initial_cap
RedisConfig.columns
RedisConfig.root_id
BackendMixin
- docarray.array.storage.redis.find module
- docarray.array.storage.redis.getsetdel module
- docarray.array.storage.redis.seqlike module
Module contents#
- class docarray.array.storage.redis.StorageMixins(*args, **kwds)[source]#
Bases:
FindMixin
,BackendMixin
,GetSetDelMixin
,SequenceLikeMixin
,ABC
- TYPE_MAP: Dict[str, TypeMap] = {'bytes': TypeMap(type='text', converter=<class 'redis.commands.search.field.TextField'>), 'double': TypeMap(type='double', converter=<class 'redis.commands.search.field.NumericField'>), 'float': TypeMap(type='float', converter=<class 'redis.commands.search.field.NumericField'>), 'geo': TypeMap(type='geo', converter=<class 'redis.commands.search.field.GeoField'>), 'int': TypeMap(type='integer', converter=<class 'redis.commands.search.field.NumericField'>), 'long': TypeMap(type='long', converter=<class 'redis.commands.search.field.NumericField'>), 'str': TypeMap(type='text', converter=<class 'redis.commands.search.field.TextField'>)}#
- append(value, **kwargs)#
Append doc to the end of the array.
- Parameters:
value (
Document
) – The doc needs to be appended.
- clear()#
Clear the data of
DocumentArray
- count(value) integer -- return number of occurrences of value #
- extend(values, **kwargs)#
S.extend(iterable) – extend sequence by appending elements from the iterable
- Return type:
None
- find(query=None, metric='cosine', limit=20, metric_name=None, exclude_self=False, filter=None, only_id=False, index='text', return_root=False, on=None, **kwargs)#
Returns matching Documents given an input query. If the query is a DocumentArray, Document or ArrayType, exhaustive or approximate nearest neighbor search will be performed depending on whether the storage backend supports ANN. Furthermore, if filter is not None, pre-filtering will be applied along with vector search. If the query is a dict object or, query is None and filter is not None, Documents will be filtered and all matching Documents that match the filter will be returned. In this case, query (if it’s dict) or filter will be used for filtering. The object must follow the backend-specific filter format if the backend supports filtering or DocArray’s query language format. In the latter case, filtering will be applied in the client side not the backend side. If the query is a string or list of strings, a search by text will be performed if the backend supports indexing and searching text fields. If not, a NotImplementedError will be raised.
- Parameters:
query (
Union
[DocumentArray
,Document
, ArrayType,Dict
,str
,List
[str
],None
]) – the input query to search bylimit (
Union
[int
,float
,None
]) – the maximum number of matches, when not given defaults to 20.metric_name (
Optional
[str
]) – if provided, then match result will be marked with this string.metric (
Union
[str
,Callable
[[ArrayType, ArrayType],ndarray
]]) – the distance metric.exclude_self (
bool
) – if set, Documents in results with sameid
as the query values will not be considered as matches. This is only applied when the input query is Document or DocumentArray.filter (
Union
[Dict
,str
,None
]) – filter query used for pre-filtering or filteringonly_id (
bool
) – if set, then returning matches will only containid
index (
str
) – if the query is a string, text search will be performed on the index field, otherwise, this parameter is ignored. By default, the Document text attribute will be used for search, otherwise the tag field specified by index will be used. You can only use this parameter if the storage backend supports searching by text.return_root (
Optional
[bool
]) – if set, then the root-level DocumentArray will be returnedon (
Optional
[str
]) – specifies a subindex to search on. If set, the returned DocumentArray will be retrieved from the given subindex.kwargs – other kwargs.
- Return type:
Union
[DocumentArray
,List
[DocumentArray
]]- Returns:
a list of DocumentArrays containing the closest Document objects for each of the queries in query.
- index(value[, start[, stop]]) integer -- return first index of value. #
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(index, value, **kwargs)#
Insert doc at index.
- Parameters:
index (
int
) – Position of the insertion.value (
Document
) – The doc needs to be inserted.kwargs – Additional Arguments that are passed to the Document Store. This has no effect for in-memory DocumentArray.
- pop([index]) item -- remove and return item at index (default last). #
Raise IndexError if list is empty or index is out of range.
- remove(value)#
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()#
S.reverse() – reverse IN PLACE
- sync()#
- class docarray.array.storage.redis.RedisConfig(n_dim, host='localhost', port=6379, index_name=None, list_like=True, update_schema=True, distance='COSINE', redis_config=<factory>, index_text=False, tag_indices=<factory>, language=None, batch_size=64, method='HNSW', ef_construction=None, m=None, ef_runtime=None, block_size=None, initial_cap=None, columns=None, root_id=True)[source]#
Bases:
object
- n_dim: int#
- host: str = 'localhost'#
- port: int = 6379#
- index_name: Optional[str] = None#
- list_like: bool = True#
- update_schema: bool = True#
- distance: str = 'COSINE'#
- redis_config: Dict[str, Any]#
- index_text: bool = False#
- tag_indices: List[str]#
- language: Optional[str] = None#
- batch_size: int = 64#
- method: str = 'HNSW'#
- ef_construction: Optional[int] = None#
- m: Optional[int] = None#
- ef_runtime: Optional[int] = None#
- block_size: Optional[int] = None#
- initial_cap: Optional[int] = None#
- columns: Optional[Union[List[Tuple[str, str]], Dict[str, str]]] = None#
- root_id: bool = True#