Pre-filtering Vector Searches
- Capella Operational
- how-to
You can specify filters as part of a Vector Search query object to restrict the documents searched in a Search index.
About Pre-filtering
Using pre-filtering as part of your vector search offers two key advantages:
-
Enhanced precision and relevance: Narrow your search results based on specific criteria, such as organization, date/time ranges, or geospatial locations.
-
Performance optimization: Reduce the search space before executing queries to improve query execution time and reduce computational overhead.
Prerequisites
-
You have the Search Service enabled on a node in your operational cluster. For more information about how to change Services on your operational cluster, see Modify a Paid Cluster.
-
You have a bucket with scopes and collections in your operational cluster. For more information, see Manage Buckets.
-
You have created a Vector Search index.
For more information about how to create a Vector Search index, see Create a Vector Search Index in Quick Mode.
You can import a sample dataset to use with the procedure or examples on this page.
Go to import the vector-sample sample data.
from your cluster andFor the best results, consider using the sample Vector Search index from Create a Vector Search Index with the Capella UI.
Procedure
To add pre-filtering to a Vector Search query:
-
On the Operational Clusters page, select the operational cluster where you created your Search index.
-
Go to
. -
Next to your Vector Search index, click Search.
-
In the Search field, enter a search query that includes a
filter
object with yourknn
object.For more information about the
filter
object, see filter. -
Press Enter or click Search.
-
(Optional) To view a document and its source collection, click a document name in the search results list.
Example: Pre-Filter A Vector Search Query For The Color "Navy"
For example, the following Vector Search query tries to find matches to a color with an RGB value of [176, 0, 176]
with a minimum brightness of 70
and a maximum of 80
.
A pre-filter on the query will narrow the documents searched inside the Vector Search index to documents that have a color
field value that closely matches navy
: