Himanshu Gaurav.nb
ENTERPRISE AI / Towards Data Experience

Find What Matters with Context: Vector Search for Retail Teams on Databricks— Part 1

If you’ve ever worked in a retailer’s product team, you know the journey from an initial idea to an actual product on the shelf is anything...

Originally published on Medium ↗ on 2025-07-07. This edition preserves the original article text.

(Credit: ChatGPT)
(Credit: ChatGPT)

If you’ve ever worked in a retailer’s product team, you know the journey from an initial idea to an actual product on the shelf is anything but linear. The GTM for many retailers remains more than 12 months away.

You’re not just thinking, “What’s the next bestselling jacket?” — you’re navigating a maze of decisions across fabric textures, material types, cost constraints, style inspirations, and vendor capabilities. It’s part art, part science — and a whole lot of data. Additionally, your enterprise is likely sitting on a goldmine of master data — including materials, fabrics, vendors, costs, past styles, and sourcing history — all stored across various systems, teams, and spreadsheets.
From Idea to Sample product in retail with Vector Search(Credit :Napkin AI)
From Idea to Sample product in retail with Vector Search(Credit :Napkin AI)

In this first part, we’ll explore the power of similarity search with vector databases in Databricks, focusing on how it aids analysts in quickly finding answers using SQL. This capability is essential for uncovering insights and trends efficiently.

Stay tuned for part 2, where we’ll discuss how easy it is to integrate a language model (LLM) and an application layer to make the search intelligent, allowing non-technical users to engage in natural language conversations and receive instant answers to their queries. Exciting advancements in data analytics are on the horizon!

The theme being “Ease of Use”.

The Problem: Rigid Search Is Failing Product Teams

Most product development and sourcing teams still rely on dropdown filters, keyword search, or string-based queries. And while that works for exact matches, it completely breaks down when your needs are fuzzy or semantic.

You can’t always type:

“Give me exactly the same nylon-blend material from last season”

Instead, the need is more like:

“Show me materials similar to this spandex-nylon combo, but with a lower cost and a vendor we’ve used before.”

This is where traditional search collapses. It’s rigid. Literal. And blind to context.

The Need: Semantic Similarity, Not Just Filtering

Retail data is rich, but it’s also messy. Two materials might have:

  • Different names
  • Slightly varied descriptions
  • Identical fiber content but from different vendors
  • Slightly higher or lower costs

With traditional SQL search, you’re left writing brittle queries like:

Figure 3 from Find What Matters with Context: Vector Search for Retail Teams on Databricks— Part 1

But this won’t catch things like:

  • “Spandex-polyester blends that feel like nylon”
  • “Sustainable equivalents with similar vendor ratings”
  • “Past season fabrics with equivalent texture and stretch”

You need semantic, meaningful discovery — not pattern matching.

The Solution: Vector Search in Databricks

What is Vector Search in layman's terms?

Vector Search is a method for finding and retrieving unstructured data, such as images, text, or audio, that has been converted into numerical representations and stored in a specialized database.
Imagine you have a collection of items: words, sentences, images, or even songs. Each item is processed through a special “embedding model” that converts it into a list of numbers (a vector). This list captures the meaning or features of the item. Think of a large map where each item is a dot. Items with similar meanings are placed close together, even if they don’t use the same words. For example, two different products made with cotton, “shirt” and “shorts,” would be near each other, but “” would be far away.
Each item is converted into a list of numbers (an embedding) that captures its features and meaning. For example:

Product A: [0.8, 0.2, 0.5]

Product B: [0.82, 0.18, 0.52]

Product C: [0.1, 0.9, 0.3]

Each product’s embedding is like a point on a map. Products with similar materials and costs will have embeddings (points) close together.

For example, two cotton shirts with similar prices will be near each other, while a leather bag with a high price will be farther away. When you search for a product (e.g., “affordable cotton shirt”), your query is also turned into an embedding, such as [0.81, 0.21, 0.48].

The system finds products whose embeddings are closest to your query’s embedding. The closest products are those most similar in terms of material and cost, not just in terms of exact words.

Representation of Vector Embedding
Representation of Vector Embedding

Enter Vector Search on Databricks — a way to make your material, vendor, and product data searchable by meaning, not just by string match.

With vector embeddings, your team can:

  • Find similar fabrics, materials, or trims based on description, not just exact terms
  • Explore alternative vendors based on past performance and cost range
  • Enable product designers to explore the catalog semantically, like a human, not a database

A Real Retail Use Case

A sourcing manager seeks fabric options similar to a nylon-cotton blend, ideally priced under $1.50 per yard and sourced from a trusted vendor.

They aren’t sure what exact words were used in the past catalog — just the feel and fiber content.

Traditional search: Too brittle
Vector search: Learns the meaning behind the material description and returns ranked, relevant matches.

Step-by-Step: Implementing Vector Search in Databricks (with SQL)

If you are on Databricks, then, most importantly, your master data around materials, products, vendors, and costs would already be in the lakehouse. It can exist in different tables, but you can join them yourself or ask your data engineering to join these tables and consolidate the required field in one table.

Considering the required fields are consolidated in one table, I will show you how it’s done in SQL or using the GUI with Databricks' built-in capabilities.

Step 1: Create a Final Table by joining the relevant columns from the various tables, including Product, Cost, Vendor, Color, etc.

Let’s take a look at the final table structure below. Please consult your Data Engineering team for assistance, as this should be a quick task for them. Additionally, you can automate the pipeline, as it will primarily involve straightforward joins and simple transformations. Additionally, concatenate all the columns on which you would like to run a search into a new column, as shown in the snapshot below, where I have labeled this new column as “text_descr”.

Figure 5 from Find What Matters with Context: Vector Search for Retail Teams on Databricks— Part 1
Figure 6 from Find What Matters with Context: Vector Search for Retail Teams on Databricks— Part 1

Step 2.1: Create a vector-serving endpoint

In Databricks, vector search endpoints let you find data based on similarity from the vector index. It helps in apps like recommendations and RAG, and it scales automatically. The vector serving endpoint can be created as per the steps in the snapshot below.

  1. Select the compute option in the left pane.
  2. Select the Vector Search option.
  3. Click on the Create Endpoint option.
  4. Provide the endpoint name and click confirm, which will provision the endpoint.
Figure 7 from Find What Matters with Context: Vector Search for Retail Teams on Databricks— Part 1

Step 2.2: Create a vector index on the table

Find the table in Unity Catalog and click on it to open a right pane. This can be done programmatically or via a UI interface. In the Databricks Catalog panel, select the table where you want to create the final vector search index, following the highlighted steps in the snapshot below (Step 1).

  1. Select the table on which you want to build the vector search index.I have selected the table that we created in step 1.
  2. Click the Create button at the top right corner.
  3. Choose 'Vector Search Index' from the dropdown menu.
Create Vector Serach Index — Step 1
Create Vector Serach Index — Step 1

It opens a new pop-up window; please fill in the details as shown in the snapshot below (step 2).

  1. Name: For Unity Catalog’s online table (three-level namespace).
  2. Primary key: Select a column as the primary key.
  3. Endpoint: Choose the vector search endpoint created in the above step.
  4. Columns to sync: Select columns to sync; all columns are synced if left blank, including primary key and embedding columns.
  5. Embedding source:

- Compute embeddings: Select text column and endpoint; use for large-scale embedding with pay-per-token models. Two popular and commonly used embedding models to consider when starting with Databricks Vector Search are:

a. databricks-gte-large-en: Databricks recommends this pay-per-token foundation model for large-scale embedding generation due to its higher throughput.

b. BGE Large: This model is another widely adopted choice and is available out of the box on Databricks.

6. Sync computed embeddings: Toggle to save embeddings to the catalog.

7. Sync mode:

  • Continuous: Real-time sync with higher cost (incremental for standard, complete rebuild for storage endpoints).
  • Triggered: Manual start via SDK or API; only supported for storage-optimized endpoints. We will go with this for now.

8. Finish by clicking ‘Create’.

Create Vector Search Index — Step 2
Create Vector Search Index — Step 2

Step 3: Vector Index Created on the final table

Once you hit 'Create,' wait for a few minutes, depending on the volume of the table, for the sync to complete. When it’s ready, the screen will appear as shown in the snapshot below.

Vector Index Created Successfully
Vector Index Created Successfully

Step 4: Querying the data in the Vector index for Similarity Search leveraging SQL

You can query this vector index either via. SQL or using a Python snippet. Let’s query this for the similarity search pattern we stated earlier, “similar to a nylon-spandex blend”. I am using a vector search() function, which allows you to query a vector search index using SQL.

You can also create a UDF in either SQL or Python and abstract the complexity from users and share an easy method of calling the UDF, just with the search pattern and number of rows returned.
Figure 11 from Find What Matters with Context: Vector Search for Retail Teams on Databricks— Part 1

Important Observation on the Search Results

The similarity search works as expected, and you can experiment with your dataset to gain a deeper understanding of it. Still, it doesn’t return accurate results for specific scalar filter requests, like finding the lowest cost, a particular color, or the vendor with the highest ratings. These kinds of requirements need filter vector search or hybrid search, a technique used in vector databases that combines the power of vector similarity search with traditional attribute-based filtering.

The core idea is to retrieve vectors that are both semantically similar to the query vector and satisfy the specified scalar filter conditions.
Filtered Vector Search
Filtered Vector Search

You will need to use a combination of Vector and Scalar searches to get your intended output. This works well for teams with SQL or Python skill sets.

The Outcome

Your product and sourcing teams can now:

  • Search smarter, faster, and more intuitively
  • Discover materials or vendors they wouldn’t have otherwise
  • Make better decisions without rewriting complex filters or asking engineering for help
Best of all?
You’re unlocking the full potential of the data you already have — right there in your Lakehouse on the Databricks Platform.

Final Thought

Vector search offers a significant upgrade to traditional retail data search by enabling semantic understanding, rather than relying solely on rigid string or pattern matching. For product teams, this means you can finally search by meaning, not just by exact matches — discovering materials, vendors, or styles that are similar in the way humans think, not just how databases filter.

Most product managers or merchandisers don’t speak in vectors or embedding terms. They want to ask natural questions like:

“What sustainable fabrics can I use under $2/yard that feel like brushed cotton?”

That’s where the next leap comes in — combining vector search with LLMs and natural language interfaces to deliver intelligent, intuitive search experiences tailored for business users.

In Part 2, we’ll show how to layer LLMs and build a simple NLP-powered app on top of your vector index, all in the Databricks Platform, making search as easy as asking a question.

Stay tuned. We’re just getting started.

References:

https://docs.databricks.com/aws/en/generative-ai/create-query-vector-search

https://docs.databricks.com/aws/en/sql/language-manual/functions/vector_search

I hope you found it helpful! Thanks for reading!

Let’s connect on Linkedin!

Link to Blogs on various topics in Data Space

https://medium.com/@DataEnthusiast

Author

Himanshu Gaurav — www.linkedin.com/in/himanshugaurav21

Note: Please note that all opinions expressed in all the blogs are solely my own and do not reflect the views or opinions of any organization or entity I may be affiliated with.