---
schema_version: "1"
id: 381905cf057c1c76217d6d8613ec625f9a286eb61ad88fce50a8756c21148c43
title: Run Vector Searches Using Query API
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/data/264-0-0/c360_a_search_index_query.md
canonical_url: https://help.salesforce.com/s/articleView?id=data.c360_a_search_index_query.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 2864187a7b4c39a4412420ced75b831b699cb8996860a93151acc28ed23bda36
description: Use the Query API to run vector searches in Data 360. Use these examples as starting points.
products:
  - Data 360
release: "264"
---
# Run Vector Searches Using Query API

Use the Query API to run vector searches in Data 360. Use these examples as starting points.

You can use Data 360 SQL to write custom vector search statements. With the Data 360 Query API you can use these SQL statements in your custom applications.

## Basic Vector Search

This syntax performs a vector search across an index data model object (DMO) to find the defined string.

```sql
    
SELECT * 
FROM vector_search(TABLE(<Your_Vector_Embedding DMO>), 
  '<Search_String>', 
  '<PreFilteringColumn><Operator>"<Value>"', 
  '<k=topK results>'
)
```

Where:

<Your\_Vector\_Embedding>

The API name of the index DMO.

Search\_String

The search string for the vector search.

PrefilteringColumn

A boolean expression that filters the scalar fields of the primary key field to limit the search. For more information about pre-filtering, see [Vector Search Query Expressions and Pre-Filtering](https://help.salesforce.com/s/articleView?id=data.c360_a_search_index_query_prefilters.htm&release=264.0.0&type=5 "Enhance your vector search queries with pre-filtering fields. Use logical operators and manage case sensitivity for field names and values to ensure precise data retrieval.").

k=topK\_results

The number of the most similar results to return.

## Vector Search With Index and Chunk DMOs

This syntax performs a vector search across an index DMO and a chunk DMO.

```sql

SELECT
  v.score__c AS Score__c,
  c.chunk__c AS Chunk__c
FROM
  vector_search(
    TABLE(<Your_Vector_Embedding_DMO>),
    '<Search_String>',
    'language = \'English\' AND status = \'active\'',
    10
    ) v
JOIN
  <Your Chunk DMO> c ON v.RecordId__c = c.RecordId__c
  AND c.KQ_RecordId__c IS NOT DISTINCT FROM v.KQ_RecordId__c
ORDER BY 1
LIMIT 10
      
```

Where:

Score\_\_c

The similarity score of each vector to the input search string.

Chunk\_\_c

The chunk that was used to generate the vector embedding.

language=\\'English\\' AND status=\\'active\\'

An example of prefiltering with two filters. These filters are combined using the logical `AND` operator.

10

Returns the top 10 results.

<Your Chunk DMO>

The API name of the chunk DMO.

RecordId\_\_c and KQ\_RecordId\_\_c

The join statement matches on both the RecordID and the key qualified record ID while avoiding NULL values. When joining DMOs and DLOs, use key qualifiers to avoid ID overlap.

## Vector Search with DMOs and Unstructured Data Model Objects (UDMO)

This example performs a vector search, retrieves the relevant text chunks and their scores, provides the file paths of the source documents for the chunks, and returns the top 10 results.

```sql

SELECT
  v.score__c AS Score__c,
  c.chunk__c AS Chunk__c,
  u.FilePath__c AS FilePath__c
FROM
  vector_search(TABLE(<Your Vector_Embedding DMO>), '<Search String>', '', 10) v
JOIN
  <Your_Chunk_DMO> c ON v.RecordId__c = c.RecordId__c
  AND c.KQ_RecordId__c IS NOT DISTINCT FROM v.KQ_RecordId__c
JOIN
  <Your_UDMO> u ON c.SourceRecordId__c = u.FilePath__c
ORDER BY 1 DESC
LIMIT 10;
      
```

Where:

Your\_UDMO

The API name of the UDMO used to create the chunks.

FilePath\_\_c

The relative path of each file that was used to create the chunks and vector embeddings.

- **[Vector Search Query Expressions and Pre-Filtering](https://help.salesforce.com/s/articleView?id=data.c360_a_search_index_query_prefilters.htm&release=264.0.0&type=5)**  
    Enhance your vector search queries with pre-filtering fields. Use logical operators and manage case sensitivity for field names and values to ensure precise data retrieval.

#### See Also

- [_Salesforce Developer:_: Data 360 Query Guide](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/data-cloud-sql-context.html)
- [_Salesforce Help_: Creating Search Index Configurations](https://help.salesforce.com/s/articleView?id=data.c360_a_search_index_create_vector_index_config.htm&release=264.0.0&type=5 "When you create a vector search index configuration for a data model object, Data 360 breaks up the referenced data into semantically related chunks and generates searchable vectors. Your RAG and agent workflows use these vectors to find and return semantically similar items when they run queries. To get more granular control over your search index configuration, use the advanced setup, which guides you through each step of the process.")