Skip to content

OpenSearch API#

You can obtain an OpenSearchApi handle via Project.get_opensearch_api.

OpenSearchApi #

get_default_py_config #

get_default_py_config() -> dict[str, Any]

Get the required opensearch configuration to setup a connection using the opensearch-py library.

import hopsworks
from opensearchpy import OpenSearch

project = hopsworks.login()

opensearch_api = project.get_opensearch_api()

client = OpenSearch(**opensearch_api.get_default_py_config())
RETURNS DESCRIPTION
dict[str, Any]

A dictionary with required configuration.

get_project_index #

get_project_index(index: str) -> str

This helper method prefixes the supplied index name with the project name to avoid index name clashes.

PARAMETER DESCRIPTION
index

The opensearch index to interact with.

TYPE: str

RETURNS DESCRIPTION
str

A valid opensearch index name.

OpensearchRequestOption #

get_options classmethod #

get_options(options: dict)

Construct a map of options for the request to the vector database.

PARAMETER DESCRIPTION
options

The options used for the request to the vector database. The keys are attribute values of the OpensearchRequestOption class.

TYPE: dict

RETURNS DESCRIPTION
dict

A dictionary containing the constructed options map, where keys represent

attribute values of the OpensearchRequestOption class, and values are obtained

either from the provided options or default values if not available.