Skip to content

hopsworks.core.search_api #

SearchApi #

feature_groups #

feature_groups(
    search_term: str | None = None,
    keyword_filter: str | list[str] | None = None,
    tag_filter: dict[str, str]
    | list[dict[str, str] | TagSearchFilter]
    | None = None,
    offset: int = 0,
    limit: int = 100,
    global_search: bool = False,
) -> list[FeatureGroupSearchResult]

Search for feature groups only.

PARAMETER DESCRIPTION
search_term

The term to search for.

TYPE: str | None DEFAULT: None

keyword_filter

Filter results by keywords. Can be a single string or an array of strings.

TYPE: str | list[str] | None DEFAULT: None

tag_filter

Filter results by tags. Can be a single dictionary, an array of dictionaries, or an array of TagSearchFilter objects. Each tag filter requires: "name" (the tag schema name as defined by Hopsworks Admin), "key" (the property within that tag schema), and "value" (the value to match).

TYPE: dict[str, str] | list[dict[str, str] | TagSearchFilter] | None DEFAULT: None

offset

The number of results to skip.

TYPE: int DEFAULT: 0

limit

The number of search results to return.

TYPE: int DEFAULT: 100

global_search

If False, search in current project only. If True, search over all projects.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
list[FeatureGroupSearchResult]

A list of metadata objects for feature groups matching the search criteria.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request

Example
import hopsworks

project = hopsworks.login()
search_api = project.get_search_api()

# Search for feature groups
fg_metas = search_api.feature_groups("customer")

for fg_meta in fg_metas:
    print(f"Feature Group: {fg_meta.name} v{fg_meta.version}")

    # Get the same FeatureGroup object as returned by featurestore.get_feature_group
    fg = fg_meta.get()

feature_store #

feature_store(
    search_term: str | None = None,
    keyword_filter: str | list[str] | None = None,
    tag_filter: dict[str, str]
    | list[dict[str, str] | TagSearchFilter]
    | None = None,
    offset: int = 0,
    limit: int = 100,
    global_search: bool = False,
) -> FeaturestoreSearchResult

Search for feature groups, feature views, training datasets, features, jobs, apps, models, deployments and agents.

PARAMETER DESCRIPTION
search_term

The term to search for.

TYPE: str | None DEFAULT: None

keyword_filter

Filter results by keywords. Can be a single string or an array of strings.

TYPE: str | list[str] | None DEFAULT: None

tag_filter

Filter results by tags. Can be a single dictionary, an array of dictionaries, or an array of TagSearchFilter objects. Each tag filter requires: "name" (the tag schema name as defined by Hopsworks Admin), "key" (the property within that tag schema), and "value" (the value to match).

TYPE: dict[str, str] | list[dict[str, str] | TagSearchFilter] | None DEFAULT: None

offset

The number of results to skip.

TYPE: int DEFAULT: 0

limit

The number of search results to return.

TYPE: int DEFAULT: 100

global_search

If False, search in current project only. If True, search over all projects.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
FeaturestoreSearchResult

The search results with one list per entity type: feature groups, feature views, training datasets, features, jobs, apps, models, deployments and agents.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request

Example
import hopsworks

project = hopsworks.login()
search_api = project.get_search_api()

# Simple search
result = search_api.feature_store("search-term")

# Access results
for fg_meta in result.feature_groups:
    print(f"Feature Group: {fg_meta.name} v{fg_meta.version}")
    print(f"Description: {fg_meta.description}")
    print(f"Highlights: {fg_meta.highlights}")

    # Get the same FeatureGroup object as returned by featurestore.get_feature_group
    fg = fg_meta.get()

# Search with a single keyword (string)
result = search_api.feature_store("search-term", keyword_filter="ml")

# Search with multiple keywords (array of strings)
result = search_api.feature_store("search-term", keyword_filter=["ml", "production"])

# Search with tag filter as a single dictionary
result = search_api.feature_store(
    "search-term",
    tag_filter={"name": "tag1", "key": "environment", "value": "production"}
)

# Search with tag filter as an array of dictionaries
result = search_api.feature_store(
    "search-term",
    tag_filter=[
        {"name": "tag1", "key": "environment", "value": "production"},
        {"name": "tag2", "key": "version", "value": "v1.0"}
    ]
)

# Search with TagSearchFilter objects
from hopsworks_common.core.search_api import TagSearchFilter
tags = [
    TagSearchFilter(name="tag1", key="environment", value="production"),
    TagSearchFilter(name="tag2", key="version", value="v1.0")
]
result = search_api.feature_store("search-term", tag_filter=tags)

# Search with both keyword_filter and tag_filter
result = search_api.feature_store(
    "search-term",
    keyword_filter=["ml", "production"],
    tag_filter=tags
)

feature_views #

feature_views(
    search_term: str | None = None,
    keyword_filter: str | list[str] | None = None,
    tag_filter: dict[str, str]
    | list[dict[str, str] | TagSearchFilter]
    | None = None,
    offset: int = 0,
    limit: int = 100,
    global_search: bool = False,
) -> list[FeatureViewSearchResult]

Search for feature views only.

PARAMETER DESCRIPTION
search_term

The term to search for.

TYPE: str | None DEFAULT: None

keyword_filter

Filter results by keywords. Can be a single string or an array of strings.

TYPE: str | list[str] | None DEFAULT: None

tag_filter

Filter results by tags. Can be a single dictionary, an array of dictionaries, or an array of TagSearchFilter objects. Each tag filter requires: name (the tag schema name as defined by Hopsworks Admin), key (the property within that tag schema), and value (the value to match).

TYPE: dict[str, str] | list[dict[str, str] | TagSearchFilter] | None DEFAULT: None

offset

The number of results to skip.

TYPE: int DEFAULT: 0

limit

The number of search results to return.

TYPE: int DEFAULT: 100

global_search

If False, search in current project only. If True, search over all projects.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
list[FeatureViewSearchResult]

A list of metadata objects for feature views matching the search criteria.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request

Example
import hopsworks

project = hopsworks.login()
search_api = project.get_search_api()

# Search for feature views
fv_metas = search_api.feature_views("customer")

for fv_meta in fv_metas:
    print(f"Feature View: {fv_meta.name} v{fv_meta.version}")

    # Get the same FeatureView object as returned by featurestore.get_feature_view
    fv = fv_meta.get()

features #

features(
    search_term: str | None = None,
    keyword_filter: str | list[str] | None = None,
    tag_filter: dict[str, str]
    | list[dict[str, str] | TagSearchFilter]
    | None = None,
    offset: int = 0,
    limit: int = 100,
    global_search: bool = False,
) -> list[FeatureSearchResult]

Search for features only.

PARAMETER DESCRIPTION
search_term

The term to search for.

TYPE: str | None DEFAULT: None

keyword_filter

Filter results by keywords. Can be a single string or an array of strings.

TYPE: str | list[str] | None DEFAULT: None

tag_filter

Filter results by tags. Can be a single dictionary, an array of dictionaries, or an array of TagSearchFilter objects. Each tag filter requires: name (the tag schema name as defined by Hopsworks Admin), key (the property within that tag schema), and value (the value to match).

TYPE: dict[str, str] | list[dict[str, str] | TagSearchFilter] | None DEFAULT: None

offset

The number of results to skip.

TYPE: int DEFAULT: 0

limit

The number of search results to return.

TYPE: int DEFAULT: 100

global_search

If False, search in current project only. If True, search over all projects.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
list[FeatureSearchResult]

A list of features matching the search criteria.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request

Example
import hopsworks

project = hopsworks.login()
search_api = project.get_search_api()

# Search for features
features = search_api.features("age")

for feature in features:
    print(f"Feature: {feature.name}")

training_datasets #

training_datasets(
    search_term: str | None = None,
    keyword_filter: str | list[str] | None = None,
    tag_filter: dict[str, str]
    | list[dict[str, str] | TagSearchFilter]
    | None = None,
    offset: int = 0,
    limit: int = 100,
    global_search: bool = False,
) -> list[TrainingDatasetSearchResult]

Search for training datasets only.

PARAMETER DESCRIPTION
search_term

The term to search for.

TYPE: str | None DEFAULT: None

keyword_filter

Filter results by keywords. Can be a single string or an array of strings.

TYPE: str | list[str] | None DEFAULT: None

tag_filter

Filter results by tags. Can be a single dictionary, an array of dictionaries, or an array of TagSearchFilter objects. Each tag filter requires: name (the tag schema name as defined by Hopsworks Admin), key (the property within that tag schema), and value (the value to match).

TYPE: dict[str, str] | list[dict[str, str] | TagSearchFilter] | None DEFAULT: None

offset

The number of results to skip.

TYPE: int DEFAULT: 0

limit

The number of search results to return.

TYPE: int DEFAULT: 100

global_search

If False, search in current project only. If True, search over all projects.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
list[TrainingDatasetSearchResult]

A list of metadata objects for training datasets matching the search criteria.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request

Example
import hopsworks

project = hopsworks.login()
search_api = project.get_search_api()

# Search for training datasets
td_metas = search_api.training_datasets("model")

for td_meta in td_metas:
    print(f"Training Dataset: {td_meta.name} v{td_meta.version}")

    # Get the same TrainingDataset object as returned by featurestore.get_training_dataset
    td = td_meta.get()

TagSearchFilter #

Filter for searching entities by tag.

key property #

Key of the tag.

name property #

Name of the tag.

value property #

Value of the tag key.

FeatureGroupSearchResult #

Bases: SearchResultItem

Search result for a Feature Group.

get #

get() -> FeatureGroup | None

Retrieve the full FeatureGroup object.

This uses the project associated with this search result to obtain a connection to the feature store and then fetches the Feature Group with the given name and version.

RETURNS DESCRIPTION
FeatureGroup | None

The full Feature Group object corresponding to this search result.

RAISES DESCRIPTION
Exception

If the connection to the feature store fails or the Feature Group cannot be retrieved.

FeatureViewSearchResult #

Bases: SearchResultItem

Search result for a Feature View.

get #

get() -> FeatureView | None

Retrieve the full FeatureView object.

This uses the project associated with this search result to obtain a connection to the feature store and then fetches the Feature View with the given name and version.

RETURNS DESCRIPTION
FeatureView | None

The full FeatureView instance corresponding to this search result.

RAISES DESCRIPTION
Exception

If the connection to the feature store fails or the Feature View cannot be retrieved.

FeaturestoreSearchResult #

Every bucket of a search: feature store entities, jobs, apps, models, deployments and agents.

agents property #

List of Agent search results.

agents_offset property #

agents_offset: int

Total offset for the return list of agents within the whole result.

agents_total property #

agents_total: int

Total number of Agents matching the search.

apps property #

List of App search results.

apps_offset property #

apps_offset: int

Total offset for the return list of apps within the whole result.

apps_total property #

apps_total: int

Total number of Apps matching the search.

deployments property #

deployments: list[SearchResultItem]

List of Deployment search results.

deployments_offset property #

deployments_offset: int

Total offset for the return list of deployments within the whole result.

deployments_total property #

deployments_total: int

Total number of Deployments matching the search.

feature_groups property #

feature_groups: list[FeatureGroupSearchResult]

List of Feature Group search results.

feature_groups_offset property #

feature_groups_offset: int

Total offset for the return list of feature groups within the whole result.

feature_groups_total property #

feature_groups_total: int

Total number of Feature Groups matching the search.

feature_views property #

feature_views: list[FeatureViewSearchResult]

List of Feature View search results.

feature_views_offset property #

feature_views_offset: int

Total offset for the return list of feature views within the whole result.

feature_views_total property #

feature_views_total: int

Total number of Feature Views matching the search.

features property #

List of Feature search results.

features_offset property #

features_offset: int

Total offset for the return list of features within the whole result.

features_total property #

features_total: int

Total number of Features matching the search.

jobs property #

List of Job search results.

jobs_offset property #

jobs_offset: int

Total offset for the return list of jobs within the whole result.

jobs_total property #

jobs_total: int

Total number of Jobs matching the search.

models property #

List of Model search results.

models_offset property #

models_offset: int

Total offset for the return list of models within the whole result.

models_total property #

models_total: int

Total number of Models matching the search.

training_datasets property #

training_datasets: list[TrainingDatasetSearchResult]

List of Training Dataset search results.

training_datasets_offset property #

training_datasets_offset: int

Total offset for the return list of training datasets within the whole result.

training_datasets_total property #

training_datasets_total: int

Total number of Training Datasets matching the search.

Highlights #

Container for search result highlights showing where matches occurred.

The results are highlighted by wrapping the matched terms in <em> tags. Check the OpenSearch Highlight Queries for more details.

description property #

description: str | None

Highlighted description with the matched parts enwrapped in <em> tags.

features property #

features: list

Highlighted features with the matched parts enwrapped in <em> tags.

keywords property #

keywords: list

Highlighted keywords with the matched parts enwrapped in <em> tags.

name property #

name: str | None

Highlighted name with the matched parts enwrapped in <em> tags.

raw_data property #

raw_data: dict

Raw highlights data.

source_feature_groups property #

source_feature_groups: list

Highlighted source feature groups with the matched parts enwrapped in <em> tags.

tags property #

tags: list

List of highlighted tags with the matched parts enwrapped in <em> tags.

has_highlights #

has_highlights() -> bool

Check if there are any highlights.

RETURNS DESCRIPTION
bool

Whether any of the highlight fields contain data.

Project #

Represents a project associated with a search result.

id property #

id: int

Project ID.

name property #

name: str

Project name.

SearchResultItem #

Base class for search result items.

description property #

Description of the resource.

highlights property #

highlights: Highlights

Search highlights showing matched terms.

href property #

URL to get the full resource.

name property #

Name of the resource.

project property #

project: Project | None

Parent project of this resource.

raw_data property #

Raw data from the search result.

version property #

Version of the resource.

TrainingDatasetSearchResult #

Bases: SearchResultItem

Search result for a Training Dataset.

get #

get() -> TrainingDataset | None

Retrieve the full TrainingDataset object.

This uses the project associated with this search result to obtain a connection to the feature store and then fetches the Training Dataset with the given name and version.

RETURNS DESCRIPTION
TrainingDataset | None

The full TrainingDataset instance corresponding to this search result.

RAISES DESCRIPTION
Exception

If the connection to the feature store fails or the Training Dataset cannot be retrieved.