Package com.google.cloud.retail.v2beta
The interfaces provided are listed below, along with usage samples.
======================= AnalyticsServiceClient =======================
Service Description: Service for managing & accessing retail search business metric. Retail recommendation business metric is currently not available.
Sample for AnalyticsServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (AnalyticsServiceClient analyticsServiceClient = AnalyticsServiceClient.create()) {
ExportAnalyticsMetricsRequest request =
ExportAnalyticsMetricsRequest.newBuilder()
.setCatalog("catalog555704345")
.setOutputConfig(OutputConfig.newBuilder().build())
.setFilter("filter-1274492040")
.build();
ExportAnalyticsMetricsResponse response =
analyticsServiceClient.exportAnalyticsMetricsAsync(request).get();
}
======================= CatalogServiceClient =======================
Service Description: Service for managing catalog configuration.
Sample for CatalogServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
Catalog catalog = Catalog.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask);
}
======================= CompletionServiceClient =======================
Service Description: Autocomplete service for retail.
This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
Sample for CompletionServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (CompletionServiceClient completionServiceClient = CompletionServiceClient.create()) {
CompleteQueryRequest request =
CompleteQueryRequest.newBuilder()
.setCatalog(CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]").toString())
.setQuery("query107944136")
.setVisitorId("visitorId1880545833")
.addAllLanguageCodes(new ArrayList<String>())
.setDeviceType("deviceType781190832")
.setDataset("dataset1443214456")
.setMaxSuggestions(618824852)
.setEnableAttributeSuggestions(true)
.setEntity("entity-1298275357")
.build();
CompleteQueryResponse response = completionServiceClient.completeQuery(request);
}
======================= ControlServiceClient =======================
Service Description: Service for modifying Control.
Sample for ControlServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ControlServiceClient controlServiceClient = ControlServiceClient.create()) {
CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]");
Control control = Control.newBuilder().build();
String controlId = "controlId-395080872";
Control response = controlServiceClient.createControl(parent, control, controlId);
}
======================= ConversationalSearchServiceClient =======================
Service Description: Service for retail conversational search.
This feature is only available for users who have Retail Conversational Search enabled. Enable Retail Conversational Search on Cloud Console before using this feature.
Sample for ConversationalSearchServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ConversationalSearchServiceClient conversationalSearchServiceClient =
ConversationalSearchServiceClient.create()) {
ConversationalSearchRequest request =
ConversationalSearchRequest.newBuilder()
.setPlacement("placement1792938725")
.setBranch(
BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString())
.setQuery("query107944136")
.addAllPageCategories(new ArrayList<String>())
.setConversationId("conversationId-1676095234")
.setSearchParams(ConversationalSearchRequest.SearchParams.newBuilder().build())
.setVisitorId("visitorId1880545833")
.setUserInfo(UserInfo.newBuilder().build())
.setConversationalFilteringSpec(
ConversationalSearchRequest.ConversationalFilteringSpec.newBuilder().build())
.putAllUserLabels(new HashMap<String, String>())
.addAllSafetySettings(new ArrayList<SafetySetting>())
.build();
ServerStream<ConversationalSearchResponse> stream =
conversationalSearchServiceClient.conversationalSearchCallable().call(request);
for (ConversationalSearchResponse response : stream) {
// Do something when a response is received.
}
}
======================= GenerativeQuestionServiceClient =======================
Service Description: Service for managing LLM generated questions in search serving.
Sample for GenerativeQuestionServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (GenerativeQuestionServiceClient generativeQuestionServiceClient =
GenerativeQuestionServiceClient.create()) {
GenerativeQuestionsFeatureConfig generativeQuestionsFeatureConfig =
GenerativeQuestionsFeatureConfig.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
GenerativeQuestionsFeatureConfig response =
generativeQuestionServiceClient.updateGenerativeQuestionsFeatureConfig(
generativeQuestionsFeatureConfig, updateMask);
}
======================= ModelServiceClient =======================
Service Description: Service for performing CRUD operations on models. Recommendation models contain all the metadata necessary to generate a set of models for the `Predict()` API. A model is queried indirectly via a ServingConfig, which associates a model with a given Placement (e.g. Frequently Bought Together on Home Page).
This service allows you to do the following:
- Initiate training of a model.
- Pause training of an existing model.
- List all the available models along with their metadata.
- Control their tuning schedule.
Sample for ModelServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]");
Model response = modelServiceClient.getModel(name);
}
======================= PredictionServiceClient =======================
Service Description: Service for making recommendation prediction.
Sample for PredictionServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (PredictionServiceClient predictionServiceClient = PredictionServiceClient.create()) {
PredictRequest request =
PredictRequest.newBuilder()
.setPlacement("placement1792938725")
.setUserEvent(UserEvent.newBuilder().build())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setFilter("filter-1274492040")
.setValidateOnly(true)
.putAllParams(new HashMap<String, Value>())
.putAllLabels(new HashMap<String, String>())
.build();
PredictResponse response = predictionServiceClient.predict(request);
}
======================= ProductServiceClient =======================
Service Description: Service for ingesting [Product][google.cloud.retail.v2beta.Product] information of the customer's website.
Sample for ProductServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ProductServiceClient productServiceClient = ProductServiceClient.create()) {
BranchName parent = BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]");
Product product = Product.newBuilder().build();
String productId = "productId-1051830678";
Product response = productServiceClient.createProduct(parent, product, productId);
}
======================= ProjectServiceClient =======================
Service Description: Service for settings at Project level.
Sample for ProjectServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ProjectServiceClient projectServiceClient = ProjectServiceClient.create()) {
AlertConfigName name = AlertConfigName.of("[PROJECT]");
AlertConfig response = projectServiceClient.getAlertConfig(name);
}
======================= SearchServiceClient =======================
Service Description: Service for search.
This feature is only available for users who have Retail Search enabled. Enable Retail Search on Cloud Console before using this feature.
Sample for SearchServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (SearchServiceClient searchServiceClient = SearchServiceClient.create()) {
SearchRequest request =
SearchRequest.newBuilder()
.setPlacement("placement1792938725")
.setBranch(
BranchName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]").toString())
.setQuery("query107944136")
.setVisitorId("visitorId1880545833")
.setUserInfo(UserInfo.newBuilder().build())
.setPageSize(883849137)
.setPageToken("pageToken873572522")
.setOffset(-1019779949)
.setFilter("filter-1274492040")
.setCanonicalFilter("canonicalFilter-722283124")
.setOrderBy("orderBy-1207110587")
.addAllFacetSpecs(new ArrayList<SearchRequest.FacetSpec>())
.setDynamicFacetSpec(SearchRequest.DynamicFacetSpec.newBuilder().build())
.setBoostSpec(SearchRequest.BoostSpec.newBuilder().build())
.setQueryExpansionSpec(SearchRequest.QueryExpansionSpec.newBuilder().build())
.addAllVariantRollupKeys(new ArrayList<String>())
.addAllPageCategories(new ArrayList<String>())
.setPersonalizationSpec(SearchRequest.PersonalizationSpec.newBuilder().build())
.putAllLabels(new HashMap<String, String>())
.setSpellCorrectionSpec(SearchRequest.SpellCorrectionSpec.newBuilder().build())
.setEntity("entity-1298275357")
.setConversationalSearchSpec(
SearchRequest.ConversationalSearchSpec.newBuilder().build())
.setTileNavigationSpec(SearchRequest.TileNavigationSpec.newBuilder().build())
.setLanguageCode("languageCode-2092349083")
.setRegionCode("regionCode-1991004415")
.setPlaceId("placeId-494224254")
.putAllUserAttributes(new HashMap<String, StringList>())
.build();
for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) {
// doThingsWith(element);
}
}
======================= ServingConfigServiceClient =======================
Service Description: Service for modifying ServingConfig.
Sample for ServingConfigServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (ServingConfigServiceClient servingConfigServiceClient =
ServingConfigServiceClient.create()) {
CatalogName parent = CatalogName.of("[PROJECT]", "[LOCATION]", "[CATALOG]");
ServingConfig servingConfig = ServingConfig.newBuilder().build();
String servingConfigId = "servingConfigId-831052759";
ServingConfig response =
servingConfigServiceClient.createServingConfig(parent, servingConfig, servingConfigId);
}
======================= UserEventServiceClient =======================
Service Description: Service for ingesting end user actions on the customer website.
Sample for UserEventServiceClient:
// This snippet has been automatically generated and should be regarded as a code template only.
// It will require modifications to work:
// - It may require correct/in-range values for request initialization.
// - It may require specifying regional endpoints when creating the service client as shown in
// https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) {
WriteUserEventRequest request =
WriteUserEventRequest.newBuilder()
.setParent("parent-995424086")
.setUserEvent(UserEvent.newBuilder().build())
.setWriteAsync(true)
.build();
UserEvent response = userEventServiceClient.writeUserEvent(request);
}
-
ClassesClassDescriptionService Description: Service for managing & accessing retail search business metric.Settings class to configure an instance of
AnalyticsServiceClient.Builder for AnalyticsServiceSettings.Service Description: Service for managing catalog configuration.Settings class to configure an instance ofCatalogServiceClient.Builder for CatalogServiceSettings.Service Description: Autocomplete service for retail.Settings class to configure an instance ofCompletionServiceClient.Builder for CompletionServiceSettings.Service Description: Service for modifying Control.Settings class to configure an instance ofControlServiceClient.Builder for ControlServiceSettings.Service Description: Service for retail conversational search.Settings class to configure an instance ofConversationalSearchServiceClient.Builder for ConversationalSearchServiceSettings.Service Description: Service for managing LLM generated questions in search serving.Settings class to configure an instance ofGenerativeQuestionServiceClient.Builder for GenerativeQuestionServiceSettings.Service Description: Service for performing CRUD operations on models.Settings class to configure an instance ofModelServiceClient.Builder for ModelServiceSettings.Service Description: Service for making recommendation prediction.Settings class to configure an instance ofPredictionServiceClient.Builder for PredictionServiceSettings.Service Description: Service for ingesting [Product][google.cloud.retail.v2beta.Product] information of the customer's website.Settings class to configure an instance ofProductServiceClient.Builder for ProductServiceSettings.Service Description: Service for settings at Project level.Settings class to configure an instance ofProjectServiceClient.Builder for ProjectServiceSettings.Service Description: Service for search.Settings class to configure an instance ofSearchServiceClient.Builder for SearchServiceSettings.Service Description: Service for modifying ServingConfig.Settings class to configure an instance ofServingConfigServiceClient.Builder for ServingConfigServiceSettings.Service Description: Service for ingesting end user actions on the customer website.Settings class to configure an instance ofUserEventServiceClient.Builder for UserEventServiceSettings.