ClassifAI
  • Documentation
  1. Indexers
  2. indexers.VectorStore.reverse_search
  • Overview
    • Function reference
  • Vectorisers
    • Vectorisers Overview
      • vectorisers
      • vectorisers.base.VectoriserBase
      • vectorisers.base.VectoriserBase.transform
    • Specific Vectorisers
      • vectorisers.huggingface.HuggingFaceVectoriser
      • vectorisers.ollama.OllamaVectoriser
      • vectorisers.gcp.GcpVectoriser
  • Indexers
    • indexers
    • indexers.VectorStore
    • indexers.VectorStore.embed
    • indexers.VectorStore.search
    • indexers.VectorStore.reverse_search
    • indexers.VectorStore.from_filespace
    • indexers.dataclasses
    • Hooks
      • indexers.hooks
      • indexers.hooks.hook_factory.HookBase
      • indexers.hooks.default_hooks
      • indexers.hooks.default_hooks.preprocessing
      • indexers.hooks.default_hooks.preprocessing.CapitalisationStandardisingHook
      • indexers.hooks.default_hooks.postprocessing
      • indexers.hooks.default_hooks.postprocessing.DeduplicationHook
      • indexers.hooks.default_hooks.postprocessing.RagHook
  • Servers
    • servers
    • servers.get_router
    • servers.get_server
    • servers.run_server
    • servers.make_endpoints
  • Evaluation
    • evaluation
    • evaluation.main
    • evaluation.main.Evaluation
    • evaluation.metrics
    • evaluation.metrics.Metric
    • evaluation.metrics.MetricResult
  • DEMO
    • Overview of Demonstrations & Examples
    • ✨ ClassifAI Demo - Introduction & Basic Usage ✨
    • Creating Your Own Vectoriser
    • VectorStore pre- and post- processing with Hooks 🪝
    • AI agents in ClassifAI
    • ClassifAI Evaluation Module - Overview and Usage

On this page

  • indexers.VectorStore.reverse_search
    • Parameters
    • Returns
    • Raises
  1. Indexers
  2. indexers.VectorStore.reverse_search

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.
indexers.VectorStore.search
indexers.VectorStore.from_filespace