This document describes how to use Vertex AI Feature Store to perform the tasks such as synchronizing an online store, serving features from an online store, and search an online feature store using an entity or embeddings, by using the Vertex AI SDK for ABAP.
Vertex AI Feature Store is a managed, cloud-native feature store service. It streamlines your ML feature management and online serving processes by letting you manage your feature data in a BigQuery table or view.
In a typical workflow of a Vertex AI Feature Store setup, you first prepare your SAP data source in BigQuery, register your data sources by creating feature groups and features, and set up online store and feature view resources. You can then serve the latest feature values online from a feature view or perform a similarity search on the online feature store. For information about how to set up your Vertex AI Feature Store, see Vertex AI Feature Store.
Once your Vertex AI Feature Store is ready for online serving, you can use the Vertex AI SDK for ABAP for the following:
- To provide the most up-to-date and accurate feature values for real-time serving during model prediction, sync your online store with the feature data source in BigQuery.
- To provide feature values from an online store for real-time applications, serve features from the online store.
- To retrieve a list of semantically similar or related entities from the online store, search using an entity or embedding.
Before you begin
Before using the Vertex AI SDK for ABAP with Vertex AI Feature Store, make sure that you or your administrators have completed the following prerequisites:
- Enabled the Vertex AI API in your Google Cloud project.
- Installed the Vertex AI SDK for ABAP in your SAP environment.
- Set up authentication to access the Vertex AI API.
- Set up online feature serving. To learn how to create and use an online store to host and serve data in BigQuery with Vertex AI Feature Store in an end-to-end workflow, see Jupyter Notebook tutorials for Vertex AI Feature Store.
Instantiate the ABAP class for Vertex AI Feature Store
To use the Vertex AI Feature Store in your ABAP application,
you instantiate the class /GOOG/CL_FEATURE_STORE
.
DATA(lo_client) = NEW /goog/cl_feature_store(
iv_key_name = 'CLIENT_KEY'
iv_location = 'LOCATION_ID'
iv_feature_store_id = 'FEATURE_ONLINE_STORE_NAME' ).
Replace the following:
CLIENT_KEY
: The client key configured for authentication.LOCATION_ID
: Region where the online store is located, such asus-central1
.FEATURE_ONLINE_STORE_NAME
: The name of the online store containing the feature view.
Sync online store
To ensure that your online store has the most up-to-date and accurate feature values for real-time serving during model prediction, you need to sync the feature view resources in your online store with the feature data source in BigQuery.
Before you begin
On-premises or any cloud edition
Because you access Vertex AI Feature Store through a regional endpoint, you need to create an RFC destination to establish connection to Vertex AI API. You then specify the RFC destination in the service mapping table.
Create an RFC destination for the Vertex AI API with the regional endpoint where your Vertex AI Feature Store resides. For example, if your Vertex AI Feature Store resides in
us-east1
, then the endpoint for the target host would beus-east1-aiplatform.googleapis.com
. For information about regional endpoints, see Service endpoint. To create an RFC destination, perform the following steps:In SAP GUI, execute the transaction code
SM59
.Create a new RFC destination. For the RFC destination that you created, make sure the Connection Type is set as follows:
G - HTTP connection to external server
.Go to the Technical Settings tab and enter the following details:
Target Host: Provide the regional endpoint where your Vertex AI Feature Store resides.
Service No.: Enter
443
. This port number is used for secure communication.
Go to the Logon & Security tab and make sure that the SSL Certificate field is set with the option DFAULT SSL Client (Standard).
Save your changes.
Configure the service mapping table for the Vertex AI API:
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG.Click ABAP SDK for Google Cloud > Basic Settings > Configure Service Mapping.
Click New Entries.
Specify the RFC destination for the Vertex AI API:
Name Service Name RFC Destination Client key for authentication. aiplatform:v1
Name of the RFC destination. - Save the new entry.
SAP BTP edition
Because you access Vertex AI Feature Store through a regional endpoint, you need to create a communication system, a communication arrangement and configure the client key accordingly.
Access the SAP Fiori launchpad of the BTP ABAP system where the ABAP SDK for Google Cloud is installed.
Go to All spaces > Administration > Communication Management.
Create a communication system:
- Open the Communication Systems app.
- Click New.
- In the New Communication System dialog that appears, enter a value for the following fields:
- System ID: enter a system ID.
- System name: enter a system name.
- Click Create.
- In the Host name field, enter the URL for the regional endpoint. For
example, if your Vertex AI Feature Store resides in
us-east1
, then the endpoint for the target host isus-east1-aiplatform.googleapis.com
. For information about regional endpoints, see Service endpoint. - In the Port field, enter
443
. - On the Users for Outbound Communication tab, click Add.
- For the Authentication method field, select None.
- Click Save.
Create a communication arrangement:
- Open the Communication Arrangement app.
- Click New.
- In the New Communication Arrangement dialog that appears, enter a value for the following fields:
- Scenario: select
Authentication using Workload Identity Federation (
/GOOG/COM_SDK_SRV
). - Arrangement name: enter a name for the communication arrangement.
- Click Create.
- For the communication arrangement entry that appears, in the Communication System field, select the communication system that you created in the previous step.
- Click Save.
Create a client key and a communication map:
- Go to the space that contains the SAP Fiori apps for SDK configuration.
- Open the Google SDK: Main Configuration app.
- Click Create.
- In the Create dialog that appears, enter a client key name.
- Click Continue.
- Enter a value for the following fields:
- Service account: enter the service account that is granted access to the Google Cloud APIs.
- Project ID: enter the project ID of the Google Cloud project where you've enabled the Google Cloud APIs. For information about project ID, see Identifying projects.
- Project number: enter the project number of the Google Cloud project where you've enabled the Google Cloud APIs. For information about project number, see Identifying projects.
- Authentication type: select W (Workload Identity Federation).
- For the communication map for the default entry of service name as "authentication", provide the communication arrangement you have set up for the WIF based authentication
- Add one more entry to the communication map and choose service as
aiplatform:v1
and provide the communication arrangement as the one you just created. - Click Create. A dialog appears confirming that you agree to use the ABAP SDK for Google Cloud under standard Google Cloud terms.
- To validate the authentication configuration, click Check connection. A green check for an entry indicates a successful configuration.
In case of any errors, see the troubleshooting guide for information about resolving common errors.
Sync Vertex AI Feature Store
To start a data sync in a feature view, you use the SYNC_FEATURE_DATA_TO_FS
method.
DATA(lv_feature_view_sync_id) = lo_client->sync_feature_data_to_fs(
iv_feature_view_id = 'FEATURE_VIEW_NAME'
)->get_feature_sync_id( ).
Replace FEATURE_VIEW_NAME
with the name of the feature view for
which you want to start the data sync.
This method returns a feature view sync ID, which can be used to check the status of the sync.
Get the status of Vertex AI Feature Store sync
To get the status of a Vertex AI Feature Store sync, you can use the
GET_FEATURE_SYNC_STATUS
method.
DATA(ls_status) = lo_client->get_feature_sync_status(
iv_feature_view_id = 'FEATURE_VIEW_NAME'
iv_feature_sync_id = 'FEATURE_VIEW_SYNC_ID'
)->get_feature_sync_status( ).
Replace the following:
FEATURE_VIEW_NAME
: The name of the feature view for which you want to check the sync status.FEATURE_VIEW_SYNC_ID
: The feature view sync ID received from Sync Vertex AI Feature Store.This method returns one of the following statuses along with the error message, if any:
C: Complete
,R: Running
, orF: Failed
Sync Vertex AI Feature Store by using an SAP background job
On-premises or any cloud edition
To start a data sync in a feature view by using an SAP background job, you can
use theSYNC_FEATURE_DATA_TO_FS_BGJOB
method.
This method creates a background job in your SAP system, which starts the feature store
sync and checks the status of the feature store sync every 30 seconds.
If the feature store sync status is completed or failed, then the background
job completes with a message accordingly.
If the feature store sync is running, then the background job runs until
the specified TIMEOUT
value. Post timeout, the background job completes,
however, the feature store sync continues to run.
DATA(ls_bgjob_details) = lo_client->sync_feature_data_to_fs_bgjob(
iv_feature_view_id = 'FEATURE_VIEW_NAME'
iv_timeout = TIMEOUT
)->get_background_job_details( ).
Replace the following:
FEATURE_VIEW_NAME
: The name of the feature view for which you want to manually start the data sync.TIMEOUT
: Time in seconds after which the background job is timed out. This doesn't impact the Vertex AI Feature Store sync.
This method returns a background job name and the corresponding ID. This job can be monitored from within SAP to check status of the feature store sync.
SAP BTP edition
You can skip this section because it doesn't apply to the SAP BTP edition of ABAP SDK for Google Cloud.
Serve features from an online store
You can serve feature values from an online store for real-time applications, such as product recommendations. Depending on the type of online serving you've configured for your online store, you can serve feature values in one of the following ways:
- Fetch feature values by using Bigtable online serving.
- Fetch feature values by using Optimized online serving with a public endpoint.
- Fetch feature values by using Optimized online serving with a Private Service Connect endpoint.
For more information about serving feature values, see Serve features from an online store.
Before you begin
On-premises or any cloud edition
Before you can start serving feature values from an online store, you need to retrieve the public endpoint domain name from the online store details, create an RFC destination for the endpoint, and then specify the RFC destination in the service mapping table.
Retrieve the public endpoint domain name for the online store:
-
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG. - Click ABAP SDK for Google Cloud > Utilities > Vertex AI SDK: Get RFC information for Feature Store and Vector Search.
- Select Get Feature Store Details.
- Enter the following parameters:
- Google Cloud Key Name: The client key for authentication to Google Cloud.
- Location: The region where the online store is located.
- Feature Store ID: The name of the online store containing the feature view.
- Click Execute to view the details. Make a note of the public endpoint domain name against the Host label.
-
In SAP GUI, execute the transaction code
Create an RFC destination for the regional endpoint, public endpoint domain name, or the Private Service Connect endpoint of the online store. To create an RFC destination, perform the following steps:
- In SAP GUI, execute the transaction code
SM59
. - Create a new RFC destination. For the RFC destination that you created,
make sure the Connection Type is set as follows:
G - HTTP connection to external server
. - Go to the Technical Settings tab and enter the following details:
Target Host: Provide the public endpoint domain name where your Vertex AI Feature Store resides.
Service No.: Enter
443
. This port number is used for secure communication.
Go to the Logon & Security tab and make sure that the SSL Certificate field is set with the option DFAULT SSL Client (Standard).
Save your changes.
- In SAP GUI, execute the transaction code
Configure the service mapping table for the Vertex AI API:
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG.Click ABAP SDK for Google Cloud > Basic Settings > Configure Service Mapping.
Click New Entries.
Specify the RFC destination for the Vertex AI API:
Name Service Name RFC Destination Client key for authentication. apiinvoker:v1
Name of the RFC destination. Save the new entry.
SAP BTP edition
Before you can start serving feature values from an online store, you need to retrieve the public endpoint domain name from the online store details. After this, you need to create a communication system and a communication arrangement and configure them in the client key configuration by using the Google SDK: Main Configuration SAP Fiori app.
To retrieve the public endpoint, create the
ZCL_GET_FEATURE_STORE_PUB_EP
in a local package of your choosing. You need to pass a valid client key, and the store ID and location of the Vertex AI Feature Store.CLASS zcl_get_feature_store_pub_ep DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES if_oo_adt_classrun. ENDCLASS. CLASS zcl_get_feature_store_pub_ep IMPLEMENTATION. METHOD if_oo_adt_classrun~main. DATA lv_ckey TYPE /goog/keyname. DATA lv_location_id TYPE string. DATA lv_fsid TYPE string. DATA lv_project_id TYPE string. DATA lv_msg TYPE string. "TODO:Developer - Pass relevant values lv_ckey = 'CLIENT_KEY'. lv_fsid = 'FEATURE_ONLINE_STORE_NAME'. lv_location_id = 'LOCATION_ID'. TRY. DATA(lo_aip) = NEW /goog/cl_aiplatform_v1( iv_key_name = lv_ckey ). lv_project_id = lo_aip->gv_project_id. " Call API method: aiplatform.projects.locations.featureOnlineStores.get lo_aip->get_feature_online_stores( EXPORTING iv_p_projects_id = lv_project_id iv_p_locations_id = lv_location_id iv_p_feature_online_stores_id = lv_fsid IMPORTING es_output = DATA(ls_output) ev_ret_code = DATA(lv_ret_code) ev_err_text = DATA(lv_err_text) ). IF lo_aip->is_success( lv_ret_code ) = abap_true. out->write( | Public endpoint is| ). out->write( ls_output-dedicated_serving_endpoint-public_endpoint_domain_name ). ENDIF. CATCH /goog/cx_sdk INTO DATA(lo_cx_sdk). lv_msg = lo_cx_sdk->get_text( ). out->write( |Exception occurred, reason: { lv_msg }| ). ENDTRY. ENDMETHOD. ENDCLASS.
Activate and execute the
ZCL_GET_FEATURE_STORE_PUB_EP
class.The output, which is the public endpoint of your online store, uses the following format:
xxxxxxxxxx.LOCATION_ID-PROJECT_ID.featurestore.vertexai.goog
This output includes the following values:
LOCATION_ID
: the region where your online store is located.PROJECT_ID
: the project ID of the Google Cloud project where your online store is located.
Access the SAP Fiori launchpad of the BTP ABAP system where the ABAP SDK for Google Cloud is installed.
Go to All spaces > Administration > Communication Management.
Create a communication system:
- Open the Communication Systems app.
- Click New.
- In the New Communication System dialog that appears, enter a value for the following fields:
- System ID: enter a system ID.
- System name: enter a system name.
- Click Create.
- In the Host name field, enter the public endpoint that you retrieved
by executing the
ZCL_GET_FEATURE_STORE_PUB_EP
class in a preceding step. - In the Port field, enter
443
. - Go to the Users for Outbound Communication tab, and click Add.
- In the Authentiation method field, select None.
- Click Save.
Create a communication arrangement:
- Open the Communication Arrangements app.
- Click New.
- In the New Communication Arrangement dialog that appears, enter a value for the following fields:
- Scenario: select
Authentication using Workload Identity Federation (
/GOOG/COM_SDK_SRV
). - Arrangement name: enter a name for the communication arrangement.
- Click Create.
- For the communication arrangement entry that appears, in the Communication System field, select the communication system that you created in the previous step.
- Click Save.
Create a client key and communication map:
- Go to the space that contains the SAP Fiori apps for SDK configuration.
- Open the Google SDK: Main Configuration app.
- Click Create.
- In the Create dialog that appears, enter a client key name.
- Click Continue.
- Enter the following details:
- Service account: enter the service account that is granted access to the Google Cloud APIs.
- Project ID: enter the project ID of the Google Cloud project where you've enabled the Google Cloud APIs. For information about project ID, see Identifying projects.
- Project number: enter the project number of the Google Cloud project where you've enabled the Google Cloud APIs. For information about project number, see Identifying projects.
- Authentication type: select W (Workload Identity Federation).
- For the communication map for the default entry of service name as "authentication", provide the communication arrangement you have set up for the WIF based authentication
- Add one more entry to the communication map and choose service as
aiplatform:v1
and provide the communication arrangement as the one you just created. - Click Create. A dialog appears confirming that you agree to use the ABAP SDK for Google Cloud under standard Google Cloud terms.
- To validate the authentication configuration, click Check connection. A green check for an entry indicates a successful configuration.
In case of any errors, see the troubleshooting guide for information about resolving common errors.
Verify that your communication map contains the following three entries:
Service name Communication scenario Communication arrangement authentication
/GOOG/SDK_COM_WIF
Communication arrangement that you've created for the XSUAA
service.aiplatform:v1
/GOOG/COM_SDK_SRV
Communication arrangement that you've set by using the communication system that contains the regional endpoint for AI PLATFORM
.apiinvoker:v1
/GOOG/COM_SDK_SRV
Communication arrangement that you've set up by using the communication system for the public endpoint for the Vertex AI Feature Store serving in the previous step.
Fetch feature values
In Vertex AI Feature Store, an entity refers to an item that you want to track features for, such as a customer, a product, or any other data point. Each entity is associated with a set of features and their corresponding values.
To fetch feature values by specifying a single entity ID, use
the method SERVE_FEATURE_VALUES
.
DATA(lt_features) = lo_client->serve_feature_values(
iv_feature_view_id = 'FEATURE_VIEW_NAME'
it_entity_id = 'ENTITY_ID'
)->get_features( ).
Replace the following:
FEATURE_VIEW_NAME
: The name of the feature view from which you want to serve feature values.ENTITY_ID
: The value of the ID column in the feature record from which you want to serve the latest feature values. Alternatively, you can provide an array of parts to construct the Entity ID. Ensure that the ID columns are in the same order as defined in the feature view.
Search for approximate nearest neighbors
For online stores created for optimized online serving, you can perform a vector similarity search to retrieve a list of semantically similar or related entities, also called approximate nearest neighbors. You can search for approximate nearest neighbors based on either an entity ID or an embedding.
Before you begin
On-premises or any cloud
When you create an online store for optimized online serving, Vertex AI Feature Store generates a public endpoint domain name for the online store. Before you can start searching for the nearest neighbors from a feature view in the online store, you need to retrieve the public endpoint domain name from the online store details, create an RFC destination for the endpoint, and then specify the RFC destination in the service mapping table.
Retrieve the public endpoint domain name for the online store:
-
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG. - Click ABAP SDK for Google Cloud > Utilities > Vertex AI SDK: Get RFC information for Feature Store and Vector Search.
- Select Get Feature Store Details.
- Enter the following parameters:
- Google Cloud Key Name: The client key for authentication to Google Cloud.
- Location: The region where the online store is located.
- Feature Store ID: The name of the online store containing the feature view.
- Click Execute to view the details. Make a note of the public endpoint domain name against the Host label.
-
In SAP GUI, execute the transaction code
Create an RFC destination for the public endpoint domain name of the online store:
In SAP GUI, execute the transaction code
SM59
.Create a new RFC destination. For the RFC destination that you created, make sure the Connection Type is set as follows:
G - HTTP connection to external server
.Go to the Technical Settings tab and enter the following details:
Target Host: Provide the public endpoint domain name for the online store.
Service No.: Enter
443
. This port number is used for secure communication.
Go to the Logon & Security tab and make sure that the SSL Certificate field is set with the option DFAULT SSL Client (Standard).
Save your changes.
Configure the service mapping table for the Vertex AI API:
-
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG. - Click ABAP SDK for Google Cloud > Basic Settings > Configure Service Mapping.
- Click New Entries.
- Specify the RFC destination for the Vertex AI API:
Name Service Name RFC Destination Client key for authentication. apiinvoker:v1
Name of the RFC destination. - Save the new entry.
-
In SAP GUI, execute the transaction code
SAP BTP edition
Before you can start serving feature values from an online store, you need to retrieve the public endpoint domain name from the online store details. After this, you need to create a communication system and a communication arrangement and configure them in the client key configuration by using the Google SDK: Main Configuration SAP Fiori app.
To retrieve the public endpoint, create the
ZCL_GET_FEATURE_STORE_PUB_EP
in a local package of your choosing. You need to pass a valid client key, and the store ID and location of the Vertex AI Feature Store.CLASS zcl_get_feature_store_pub_ep DEFINITION PUBLIC FINAL CREATE PUBLIC. PUBLIC SECTION. INTERFACES if_oo_adt_classrun. ENDCLASS. CLASS zcl_get_feature_store_pub_ep IMPLEMENTATION. METHOD if_oo_adt_classrun~main. DATA lv_ckey TYPE /goog/keyname. DATA lv_location_id TYPE string. DATA lv_fsid TYPE string. DATA lv_project_id TYPE string. DATA lv_msg TYPE string. "TODO:Developer - Pass relevant values lv_ckey = 'CLIENT_KEY'. lv_fsid = 'FEATURE_ONLINE_STORE_NAME'. lv_location_id = 'LOCATION_ID'. TRY. DATA(lo_aip) = NEW /goog/cl_aiplatform_v1( iv_key_name = lv_ckey ). lv_project_id = lo_aip->gv_project_id. " Call API method: aiplatform.projects.locations.featureOnlineStores.get lo_aip->get_feature_online_stores( EXPORTING iv_p_projects_id = lv_project_id iv_p_locations_id = lv_location_id iv_p_feature_online_stores_id = lv_fsid IMPORTING es_output = DATA(ls_output) ev_ret_code = DATA(lv_ret_code) ev_err_text = DATA(lv_err_text) ). IF lo_aip->is_success( lv_ret_code ) = abap_true. out->write( | Public endpoint is| ). out->write( ls_output-dedicated_serving_endpoint-public_endpoint_domain_name ). ENDIF. CATCH /goog/cx_sdk INTO DATA(lo_cx_sdk). lv_msg = lo_cx_sdk->get_text( ). out->write( |Exception occurred, reason: { lv_msg }| ). ENDTRY. ENDMETHOD. ENDCLASS.
Activate and execute the
ZCL_GET_FEATURE_STORE_PUB_EP
class.The output, which is the public endpoint of your online store, uses the following format:
xxxxxxxxxx.LOCATION_ID-PROJECT_ID.featurestore.vertexai.goog
This output includes the following values:
LOCATION_ID
: the region where your online store is located.PROJECT_ID
: the project ID of the Google Cloud project where your online store is located.
Access the SAP Fiori launchpad of the BTP ABAP system where the ABAP SDK for Google Cloud is installed.
Go to All spaces > Administration > Communication Management.
Create a communication system:
- Open the Communication Systems app.
- Click New.
- In the New Communication System dialog that appears, enter a value for the following fields:
- System ID: enter a system ID.
- System name: enter a system name.
- Click Create.
- In the Host name field, enter the public endpoint that you retrieved
by executing the
ZCL_GET_FEATURE_STORE_PUB_EP
class in a preceding step. - In the Port field, enter
443
. - Go to the Users for Outbound Communication tab, and click Add.
- In the Authentiation method field, select None.
- Click Save.
Create a communication arrangement:
- Open the Communication Arrangements app.
- Click New.
- In the New Communication Arrangement dialog that appears, enter a value for the following fields:
- Scenario: select
Authentication using Workload Identity Federation (
/GOOG/COM_SDK_SRV
). - Arrangement name: enter a name for the communication arrangement.
- Click Create.
- For the communication arrangement entry that appears, in the Communication System field, select the communication system that you created in the previous step.
- Click Save.
Create a client key and communication map:
- Go to the space that contains the SAP Fiori apps for SDK configuration.
- Open the Google SDK: Main Configuration app.
- Click Create.
- In the Create dialog that appears, enter a client key name.
- Click Continue.
- Enter the following details:
- Service account: enter the service account that is granted access to the Google Cloud APIs.
- Project ID: enter the project ID of the Google Cloud project where you've enabled the Google Cloud APIs. For information about project ID, see Identifying projects.
- Project number: enter the project number of the Google Cloud project where you've enabled the Google Cloud APIs. For information about project number, see Identifying projects.
- Authentication type: select W (Workload Identity Federation).
- For the communication map for the default entry of service name as "authentication", provide the communication arrangement you have set up for the WIF based authentication
- Add one more entry to the communication map and choose service as
aiplatform:v1
and provide the communication arrangement as the one you just created. - Click Create. A dialog appears confirming that you agree to use the ABAP SDK for Google Cloud under standard Google Cloud terms.
- To validate the authentication configuration, click Check connection. A green check for an entry indicates a successful configuration.
In case of any errors, see the troubleshooting guide for information about resolving common errors.
Verify that your communication map contains the following three entries:
Service name Communication scenario Communication arrangement authentication
/GOOG/SDK_COM_WIF
Communication arrangement that you've created for the XSUAA
service.aiplatform:v1
/GOOG/COM_SDK_SRV
Communication arrangement that you've set by using the communication system that contains the regional endpoint for AI PLATFORM
.apiinvoker:v1
/GOOG/COM_SDK_SRV
Communication arrangement that you've set up by using the communication system for the public endpoint for the Vertex AI Feature Store serving in the previous step.
Retrieve nearest neighbor matches of an embedding
You can search for semantically related entities by specifying an embedding.
To search nearest neighbors for an embedding, send a request by using
the SEARCH_USING_EMBEDDINGS
method.
DATA(lt_embeddings) = VALUE /goog/cl_aiplatform_v1=>ty_t_/goog/num_float( EMBEDDING_DATA ).
DATA(lt_neighbours) = lo_client->search_using_embeddings(
EXPORTING
iv_feature_view_id = 'FEATURE_VIEW_NAME'
it_embeddings = lt_embeddings
is_search_params = VALUE #( neighbor_count = 'NEIGHBOR_COUNT'
return_full_entity = 'RETURN_FULL_ENTITY' )
)->get_neighbours( ).
Replace the following:
EMBEDDING_DATA
: The embedding for which you want to retrieve the approximate nearest neighbor matches. An embedding is represented by an array of float values.FEATURE_VIEW_NAME
: The name of the feature view where you want to search for approximate nearest neighbor matches.NEIGHBOR_COUNT
: Number of approximate nearest neighbors you want to retrieve.RETURN_FULL_ENTITY
: Optional. Specify whether you want to include or exclude the features for the entities in the response. To include the features along with the entities in the response, enterABAP_TRUE
. The default value isABAP_FALSE
.
Retrieve nearest neighbor matches of an entity
You can search for semantically related entities by specifying an entity ID.
To search nearest neighbors for an entity ID, send a request by using
the SEARCH_USING_ENTITY
method.
DATA(lt_neighbours) = lo_client->search_using_entity(
EXPORTING
iv_feature_view_id = 'FEATURE_VIEW_NAME'
iv_entity_id = 'ENTITY_ID'
is_search_params = VALUE #( neighbor_count = 'NEIGHBOR_COUNT'
return_full_entity = 'RETURN_FULL_ENTITY' )
)->get_neighbours( ).
Replace the following:
FEATURE_VIEW_NAME
: The name of the feature view where you want to search for approximate nearest neighbor matches.ENTITY_ID:
: Entity ID of the entity for which you want to retrieve approximate nearest neighbor matches.NEIGHBOR_COUNT
: Number of approximate nearest neighbors that you want to retrieve.RETURN_FULL_ENTITY
: Optional. Specify whether you want to include or exclude the features for the entities in the response. To include the features along with the entities in the response, enterABAP_TRUE
. The default value isABAP_FALSE
.
What's next
- Learn about application development with the on-premises or any cloud edition of ABAP SDK for Google Cloud.
- Learn about application development with the SAP BTP edition of ABAP SDK for Google Cloud.
- Ask your questions and discuss the Vertex AI SDK for ABAP with the community on Cloud Forums.