Search API#
You can obtain a SearchApi handle by calling Project.get_search_api.
[source] SearchApi #
[source] feature_groups #
feature_groups(
search_term: str = 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: |
keyword_filter | filter results by keywords. Can be a single string or an array of strings. |
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: TYPE: |
offset | the number of results to skip (default is 0). TYPE: |
limit | the number of search results to return (default is 100). TYPE: |
global_search | By default is false - search in current project only. Set to true if you want to search over all projects TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[FeatureGroupSearchResult] |
|
| 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()
[source] feature_store #
feature_store(
search_term: str = 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 and features.
| PARAMETER | DESCRIPTION |
|---|---|
search_term | the term to search for. TYPE: |
keyword_filter | filter results by keywords. Can be a single string or an array of strings. |
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: TYPE: |
offset | the number of results to skip (default is 0). TYPE: |
limit | the number of search results to return (default is 100). TYPE: |
global_search | By default is false - search in current project only. Set to true if you want to search over all projects TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
FeaturestoreSearchResult |
|
| 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
)
[source] feature_views #
feature_views(
search_term: str = 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: |
keyword_filter | filter results by keywords. Can be a single string or an array of strings. |
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: TYPE: |
offset | the number of results to skip (default is 0). TYPE: |
limit | the number of search results to return (default is 100). TYPE: |
global_search | By default is false - search in current project only. Set to true if you want to search over all projects TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[FeatureViewSearchResult] |
|
| 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()
[source] features #
features(
search_term: str = 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: |
keyword_filter | filter results by keywords. Can be a single string or an array of strings. |
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: TYPE: |
offset | the number of results to skip (default is 0). TYPE: |
limit | the number of search results to return (default is 100). TYPE: |
global_search | By default is false - search in current project only. Set to true if you want to search over all projects TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[FeatureSearchResult] |
|
| 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}")
[source] training_datasets #
training_datasets(
search_term: str = 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: |
keyword_filter | filter results by keywords. Can be a single string or an array of strings. |
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: TYPE: |
offset | the number of results to skip (default is 0). TYPE: |
limit | the number of search results to return (default is 100). TYPE: |
global_search | By default is false - search in current project only. Set to true if you want to search over all projects TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[TrainingDatasetSearchResult] |
|
| 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()
[source] FeaturestoreSearchResult #
Container for all featurestore search results.
[source] feature_groups property #
feature_groups: list[FeatureGroupSearchResult]
List of Feature Group search results.
[source] feature_groups_offset property #
feature_groups_offset: int
Total offset for the return list of feature groups within the whole result.
[source] feature_groups_total property #
feature_groups_total: int
Total number of Feature Groups matching the search.
[source] feature_views property #
feature_views: list[FeatureViewSearchResult]
List of Feature View search results.
[source] feature_views_offset property #
feature_views_offset: int
Total offset for the return list of feature views within the whole result.
[source] feature_views_total property #
feature_views_total: int
Total number of Feature Views matching the search.
[source] features_offset property #
features_offset: int
Total offset for the return list of features within the whole result.
[source] features_total property #
features_total: int
Total number of Features matching the search.
[source] training_datasets property #
training_datasets: list[TrainingDatasetSearchResult]
List of Training Dataset search results.
[source] training_datasets_offset property #
training_datasets_offset: int
Total offset for the return list of training datasets within the whole result.
[source] FeatureGroupSearchResult #
Bases: SearchResultItem
Search result for a Feature Group.
[source] get #
get()
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 |
|---|---|
| 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. |
[source] FeatureViewSearchResult #
Bases: SearchResultItem
Search result for a Feature View.
[source] get #
get()
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 |
|---|---|
| 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. |
[source] TrainingDatasetSearchResult #
Bases: SearchResultItem
Search result for a Training Dataset.
[source] get #
get()
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 |
|---|---|
| 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. |