Before you begin
Make sure you have:- An Algolia account. Create one for free if you don’t already have one.
- A Google Cloud account and project. Select or create the project where you want to store the sample BigQuery table.
- The BigQuery API enabled for your Google Cloud project. If the BigQuery API isn’t enabled, enable it from the BigQuery API page.
- Permission to create and load BigQuery datasets and tables, create a Google service account and key, and grant IAM roles. If your organization restricts service account keys or IAM changes, ask your Google Cloud administrator to complete those steps.
Set up the Google BigQuery connector
Create a source, destination, transformation, and synchronization task for the sample BigQuery table. The source identifies the BigQuery table to read. The destination identifies the Algolia index. The transformation enriches the records. The task determines when the connector runs.Select your project in Cloud Hub
Set the quickstart variables
>_) icon.Set the variables:GOOGLE_CLOUD_PROJECT to the project you selected in Cloud Hub.
Change LOCATION to use another BigQuery location.Create the BigQuery dataset
Download the sample data
Load the sample data into BigQuery
Verify the BigQuery import
records and unique_object_ids have the same value.Create the connector service account
Grant the BigQuery permissions
Create and download the service account key
algolia-bigquery-key.json.
You upload this file when you configure the connector source.If your organization prevents service account key creation,
ask your Google Cloud administrator whether they can create an approved key for this dedicated service account.Choose the Google BigQuery connector
Configure the Google service account authentication
algolia-bigquery-key.json as the Service Account File.In Name, enter BigQuery quickstart service account,
then select Create authentication.Configure the BigQuery source
Quickstart products BigQuery source,
then select Create source.Delete the service account file
Transform the records
price_range attribute to each record.
After the connector indexes your records, you can display price_range or configure it as a facet.Select Transform using the code editor and replace the placeholder Transformation code with this function:Choose the destination index
quickstart-products as the index name.Create the destination
addObject, deleteIndex, and editSettings
ACLs.In Name, enter BigQuery quickstart products destination,
then select Create destination.Create and run an on-demand synchronization task
Verify the indexed records
quickstart-products index in the Algolia dashboard.The index contains the imported product records,
with attributes such as title, description, product_type,
price, price_range, and showcase_image.product_type as an attribute for faceting
in the quickstart-products index.Index your own BigQuery data
Authenticate the connector with a dedicated Google service account. Don’t reuse a service account that can update or delete your production BigQuery data.Authentication
Grant the service account these roles:Cloud Storage data
If the connector service account reads the table’s Cloud Storage objects directly, grant it the Storage Object Viewer role (roles/storage.objectViewer) on each source bucket.
If your organization uses a custom IAM role instead, include these permissions:
JSON key
Create a Google service account JSON key and upload the key file when you configure the BigQuery source.Customize the data you index with SQL
By default, the connector imports all rows and columns from the selected table. In the BigQuery source’s Custom SQL statement field, enter a GoogleSQL statement to filter rows, combine columns, or calculate attributes. Use%s as the placeholder for the selected table.
For example:
objectID column is suitable.
If your table uses a composite key,
return its components as a single column.
For example:
objectID in an Algolia transformation if the BigQuery source provides a stable unique identifier.Transformations
Use transformations to add computed attributes or change values before the connector indexes your records. To use a transformed attribute for search, faceting, or ranking, update the relevant index settings, such assearchableAttributes, attributesForFaceting, or customRanking.
Synchronization schedule
After you create a task, you can edit it in the Algolia dashboard to choose when the connector runs:- On demand. Run the connector manually.
- Scheduled. Select a predefined schedule or enter a custom cron expression.