docarray.array.storage.redis.find module#
- class docarray.array.storage.redis.find.FindMixin[source]#
Bases:
FindMixin
- 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)[source]#
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.