Skip to main content

Oracle AI Vector Search DocumentStore integration for Haystack

Project description

oracle-haystack

PyPI - Version PyPI - Python Version

Haystack DocumentStore backed by Oracle AI Vector Search, available in Oracle Database 23ai and later.


Installation

pip install oracle-haystack

Requires Python 3.10+ and Oracle Database 23ai (or later). No Oracle Instant Client is needed for direct TCP connections (thin mode).

Usage

from haystack.utils import Secret
from haystack_integrations.document_stores.oracle import OracleConnectionConfig, OracleDocumentStore
from haystack_integrations.components.retrievers.oracle import OracleEmbeddingRetriever

# Configure the connection
config = OracleConnectionConfig(
    user=Secret.from_env_var("ORACLE_USER"),
    password=Secret.from_env_var("ORACLE_PASSWORD"),
    dsn=Secret.from_env_var("ORACLE_DSN"),
)

# Create the document store
store = OracleDocumentStore(
    connection_config=config,
    table_name="my_documents",
    embedding_dim=768,
    distance_metric="COSINE",
    create_table_if_not_exists=True,
)

# Write documents
from haystack.dataclasses import Document
store.write_documents([
    Document(content="Oracle 23ai supports native vector search."),
])

# Retrieve by embedding
retriever = OracleEmbeddingRetriever(document_store=store, top_k=5)
results = retriever.run(query_embedding=[0.1] * 768)
print(results["documents"])

Connecting to Oracle Autonomous Database (ADB-S / wallet)

config = OracleConnectionConfig(
    user=Secret.from_env_var("ORACLE_USER"),
    password=Secret.from_env_var("ORACLE_PASSWORD"),
    dsn=Secret.from_env_var("ORACLE_DSN"),
    wallet_location="/path/to/wallet",
    wallet_password=Secret.from_env_var("WALLET_PASSWORD"),
)

Optional HNSW index

Pass create_index=True when constructing the store to build an HNSW vector index, which dramatically speeds up approximate nearest-neighbour search on large collections:

store = OracleDocumentStore(
    connection_config=config,
    table_name="my_documents",
    embedding_dim=768,
    create_index=True,
    hnsw_neighbors=32,
    hnsw_ef_construction=200,
    hnsw_accuracy=95,
)

Contributing

Refer to the general Contribution Guidelines.

Running tests

Unit tests

PYTHONPATH=src hatch run test:unit -vvv

Integration tests against a live Oracle instance

Set ORACLE_USER, ORACLE_PASSWORD, and ORACLE_DSN environment variables to point at your Oracle 23ai instance, then:

PYTHONPATH=src hatch run test:integration -vvv

Integration tests via Docker (local Oracle 23ai Free)

A docker-compose.yml is provided that runs gvenzl/oracle-free:23-slim (Oracle Database 23ai Free edition).

docker compose up -d --wait

--wait blocks until the Oracle healthcheck passes (the first boot takes 2–4 minutes while Oracle initialises its data files).

Run the full integration test suite:

PYTHONPATH=src hatch run test:integration -vvv

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oracle_haystack-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oracle_haystack-0.1.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file oracle_haystack-0.1.0.tar.gz.

File metadata

  • Download URL: oracle_haystack-0.1.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for oracle_haystack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ee1f829422e7251595b88e68f751d1b9dc750431931b2e288c3934d3c14d56cd
MD5 dad80f75fefaee25472ee56a9c656f99
BLAKE2b-256 16ba20bf3f46c7b96dd1252b8562ae7a3326da6bb5d41e88f18983d9c70f2ff5

See more details on using hashes here.

Provenance

The following attestation bundles were made for oracle_haystack-0.1.0.tar.gz:

Publisher: CI_pypi_release.yml on deepset-ai/haystack-core-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file oracle_haystack-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: oracle_haystack-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for oracle_haystack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11a2f8151c4c4cdd4c81f628dbe483098c576af7f40f708dd202575db1155afe
MD5 1b5b10ed97983e64c1844d7e29a72525
BLAKE2b-256 01d5e69b959e4d7d6a2e8f57b9fa1276e334980518bbe717c02f4d7f18b518e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for oracle_haystack-0.1.0-py3-none-any.whl:

Publisher: CI_pypi_release.yml on deepset-ai/haystack-core-integrations

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page