Jump to Content
AI & Machine Learning

Powering Intelligent Search with Cloud SQL for MySQL and Vertex AI

July 16, 2025
Julia Offerman

Software Engineer

Try Gemini 2.5

Our most intelligent model is now available on Vertex AI

Try now

Search is a critical component of many modern applications - whether searching for products in an online storefront, finding solutions to your customers’ support cases, or building the perfect playlist. But traditional keyword searches often miss the deeper meaning of data. Vector embeddings, however, capture the complexities of your data, enabling highly accurate and powerful searches. Vector embeddings are numerical representations of your data, generated by models, that help computers understand nuances and meaningfully compare data points.

Cloud SQL for MySQL’s generally available vector support allows you to store vector embeddings, build persistent indexes on them, and perform ANN search between them. Now, we have a new Vertex AI integration that makes this process easy by helping you generate vector embeddings using a simple SQL function, eliminating the need for external embedding generation. You can also leverage any Vertex AI model directly from MySQL, bringing advanced AI capabilities closer to your data.

Ready to see how AI can improve searches in your application and help you understand and predict customer trends? Let’s dive in.

Generate, store, & search vector embeddings

Let’s say you have an ecommerce application and are looking to see how Vertex AI and vector search with Cloud SQL for MySQL can power product searches and help you analyze customer reviews.

After setting up Vertex AI permissions and enabling the feature, you can start embedding your existing product data with the `mysql.ml_embedding` function. You just need to specify the model name and then pass the text you would like to embed–all formatting and parsing of Vertex AI requests is handled for you. 

For example, in your ecommerce application you can use a query like the following to directly store the output of `mysql.ml_embedding` in a VECTOR type column:

lang-sql
Loading...

To quickly find similar products, create a vector index for ANN search. You can select the best distance measure for your use case and customize the number of leaves to fine-tune speed and recall.

lang-sql
Loading...

When a customer searches in your application, you can embed their query using `mysql.ml_embedding` and pass it to ANN search. For example, to find clothes for a specific occasion in your database:

lang-sql
Loading...

Get responses from Gemini & other Vertex AI models

The Cloud SQL Vertex AI integration lets you make requests to any Vertex AI endpoint, including custom models fine-tuned to your datasets or pre-trained models like Gemini. This means that in addition to being able to generate vector embeddings for product descriptions, you can use Vertex AI to make predictions about things like what your users will purchase or whether a purchase is fraud.

For example, say you store customer reviews of your products in a MySQL database and want to perform analysis on them to get an idea of customer sentiment. You can invoke a Vertex AI LLM to determine customer satisfaction directly from the MySQL client and store its assessment.

Loading...

Start building

Want to get started with the MySQL Vertex AI integration after seeing how it enhances product search and analysis? Explore our detailed codelab for an embeddings workflow tutorial or dive into our documentation for a comprehensive overview of all capabilities.

Posted in