Search with Advanced Options

Optionally use the advanced_options parameter of the query operation to further customize semantic searches.

For details about implementing the query operation using Python, Curl, and PL/SQL, see Semantic Search.

The advanced_options (advancedOptions when using a Curl request) parameter can be used to provide search tuning parameters. The following are supported:

See the following for a Python example of a semantic search using query with advanced_options to specify a distance metric and target accuracy:

from oracle_vecdb import OracleVecDB, Configuration

client = OracleVecDB(Configuration(
    rest_url="https://<host>/ords/<schema>/_/db-api/stable/vecdb/",
    access_token="<bearer-token>", # or username="<user>", password="<pass>"
))

#search using a specified distance metric
distance_metric_results = client.query(
    table_name='products',
    query_by={'text': 'laptop'},
    top_k=10,
    advanced_options={
        'distance_metric': 'EUCLIDEAN',
        'accuracy': 95,
        'idx_parameters': {
            'efsearch': 128,
            'rescore_factor': 2
        }
    },
    include_vectors=True,
    output_selector=["category", "price"],
)

print(distance_metric_results)

Example response:

{
    "items": [
        {
            "id": "prod_001",
            "metadata": {
                "name": "Aurora Trail Boots",
                "category": "footwear",
                "price": 129.99,
                "color": "midnight blue"
            },
            "vector": null,
            "distance": 0.0
        },
        {
            "id": "prod_008",
            "metadata": {
                "name": "Glacier Insulated Bottle",
                "category": "accessories",
                "price": 34.0,
                "color": "arctic white"
            },
            "vector": null,
            "distance": 0.00393
        }
    ]
}