Write MQL with Gemini assistance

This document describes how you can use Gemini Code Assist to get AI-powered assistance in Cloud Firestore to generate MQL queries using natural language prompts.

Learn how and when Gemini for Google Cloud uses your data .

Before you begin

  1. Optional: Set up Gemini Code Assist .

  2. To complete the tasks in this document, ensure that you have the necessary Identity and Access Management (IAM) permissions .

Required roles

To get the permissions that you need to complete the tasks in this document, ask your administrator to grant you the Gemini for Google Cloud User ( roles/cloudaicompanion.user ) IAM role on the project.

Generate MQL queries using natural language prompts

You can give Gemini natural language comments (or prompts ) to generate queries that are based on your schema. For example, you can prompt Gemini to generate MQL in response to the following prompts:

  • "How many popular books with publication year 1960?"
  • "Create a sample collection of popular books."

To generate MQL in Cloud Firestore with Gemini assistance, follow these steps:

  1. In the Google Cloud console, go to the Cloud Firestore Databasespage.

    Go to Databases

  2. Select an Cloud Firestore database from the list. The Firestore Studioopens.

  3. In a new or empty query editor, click the Generate MQLbutton. Otherwise, click Help me code.

  4. Enter a prompt to use to generate a query. To improve accuracy, select a collection for context in the drop-down.

  5. Review the generated MQL and take any of the following actions:

    • To accept MQL generated by Gemini , click Insert. You can continue to edit the MQL in the editor. Click Runto run you query.
    • To edit your prompt, click Edit.

What's next

Create a Mobile Website
View Site in Mobile | Classic
Share by: