indexers.VectorStore.reverse_search
indexers.VectorStore.reverse_search(
query,
max_n_results=100,
partial_match=False,
)Looks up documents in vectors by label.
Performs a label-based (non-semantic) lookup against the stored documents using a VectorStoreReverseSearchInput. For each query entry, matching documents are found by comparing the query’s doc_label against the label column of self.vectors. When partial_match is enabled, a document is considered a match if its label starts with the query label.
Any preprocessing hooks set on the instance are applied to the input before searching, and any postprocessing hooks are applied to the output before it is returned.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| query | VectorStoreReverseSearchInput | Input object containing the doc labels to look up in self.vectors and their corresponding ids. | required |
| max_n_results | int | Maximum number of matching documents to return per query entry. Pass -1 to return all matches. Defaults to 100. | 100 |
| partial_match | bool | If True, matches documents whose label starts with the query label (prefix matching). If False, only exact label matches are returned. Defaults to False. | False |
Returns
| Name | Type | Description |
|---|---|---|
| VectorStoreReverseSearchOutput | VectorStoreReverseSearchOutput | Output object containing the matched documents, with columns for id, searched_doc_label, doc_label, doc_text, and any metadata columns configured on the VectorStore. |
Raises
| Name | Type | Description |
|---|---|---|
| DataValidationError | Raised if invalid arguments are passed. | |
| HookError | Raised if a preprocessing or postprocessing hook raises an exception. | |
| ClassifaiError | Raised if the reverse search operation fails. |