google-cloud-retail overview (2.4.0)

com.google.cloud.retail.v2

A client to Retail API

The interfaces provided are listed below, along with usage samples.

CatalogServiceClient

Service Description: Service for managing catalog configuration.

Sample for CatalogServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
   Catalog catalog = Catalog.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask);
 }
 

CompletionServiceClient

Service Description: Auto-completion service for retail.

This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.

Sample for CompletionServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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)
           .build();
   CompleteQueryResponse response = completionServiceClient.completeQuery(request);
 }
 

PredictionServiceClient

Service Description: Service for making recommendation prediction.

Sample for PredictionServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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 information of the customer's website.

Sample for ProductServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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);
 }
 

SearchServiceClient

Service Description: Service for search.

This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.

Sample for SearchServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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())
           .build();
   for (SearchResponse.SearchResult element : searchServiceClient.search(request).iterateAll()) {
     // doThingsWith(element);
   }
 }
 

UserEventServiceClient

Service Description: Service for ingesting end user actions on the customer website.

Sample for UserEventServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) {
   WriteUserEventRequest request =
       WriteUserEventRequest.newBuilder()
           .setParent("parent-995424086")
           .setUserEvent(UserEvent.newBuilder().build())
           .build();
   UserEvent response = userEventServiceClient.writeUserEvent(request);
 }
 

com.google.cloud.retail.v2.stub

com.google.cloud.retail.v2alpha

A client to Retail API

The interfaces provided are listed below, along with usage samples.

CatalogServiceClient

Service Description: Service for managing catalog configuration.

Sample for CatalogServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
   Catalog catalog = Catalog.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask);
 }
 

CompletionServiceClient

Service Description: Auto-completion service for retail.

This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.

Sample for CompletionServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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)
           .build();
   CompleteQueryResponse response = completionServiceClient.completeQuery(request);
 }
 

ControlServiceClient

Service Description: Service for modifying Control.

Sample for ControlServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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);
 }
 

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 customers to e.g.:

  • 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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (ModelServiceClient modelServiceClient = ModelServiceClient.create()) {
   ModelName name = ModelName.of("[PROJECT]", "[LOCATION]", "[CATALOG]", "[MODEL]");
   Model response = modelServiceClient.pauseModel(name);
 }
 

PredictionServiceClient

Service Description: Service for making recommendation prediction.

Sample for PredictionServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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 information of the customer's website.

Sample for ProductServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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);
 }
 

SearchServiceClient

Service Description: Service for search.

This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.

Sample for SearchServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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())
           .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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) {
   WriteUserEventRequest request =
       WriteUserEventRequest.newBuilder()
           .setParent("parent-995424086")
           .setUserEvent(UserEvent.newBuilder().build())
           .build();
   UserEvent response = userEventServiceClient.writeUserEvent(request);
 }
 

com.google.cloud.retail.v2alpha.stub

com.google.cloud.retail.v2beta

A client to Retail API

The interfaces provided are listed below, along with usage samples.

CatalogServiceClient

Service Description: Service for managing catalog configuration.

Sample for CatalogServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (CatalogServiceClient catalogServiceClient = CatalogServiceClient.create()) {
   Catalog catalog = Catalog.newBuilder().build();
   FieldMask updateMask = FieldMask.newBuilder().build();
   Catalog response = catalogServiceClient.updateCatalog(catalog, updateMask);
 }
 

CompletionServiceClient

Service Description: Auto-completion service for retail.

This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.

Sample for CompletionServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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)
           .build();
   CompleteQueryResponse response = completionServiceClient.completeQuery(request);
 }
 

ControlServiceClient

Service Description: Service for modifying Control.

Sample for ControlServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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);
 }
 

PredictionServiceClient

Service Description: Service for making recommendation prediction.

Sample for PredictionServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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 information of the customer's website.

Sample for ProductServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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);
 }
 

SearchServiceClient

Service Description: Service for search.

This feature is only available for users who have Retail Search enabled. Please enable Retail Search on Cloud Console before using this feature.

Sample for SearchServiceClient:


 // This snippet has been automatically generated for illustrative purposes only.
 // It may require modifications to work in your environment.
 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())
           .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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 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 for illustrative purposes only.
 // It may require modifications to work in your environment.
 try (UserEventServiceClient userEventServiceClient = UserEventServiceClient.create()) {
   WriteUserEventRequest request =
       WriteUserEventRequest.newBuilder()
           .setParent("parent-995424086")
           .setUserEvent(UserEvent.newBuilder().build())
           .build();
   UserEvent response = userEventServiceClient.writeUserEvent(request);
 }
 

com.google.cloud.retail.v2beta.stub