Skip to content

Commit 9fcdd14

Browse files
[DOC-12609]: Document the extension to vector syntax to support pre filtering: MB-62230 (#285) (#316)
* [DOC-12609]: Document the extension to vector syntax to support pre filtering: MB-62230 (#285) * [DOC-12609]: Document the extension to vector syntax to support pre filtering: MB-62230 * [DOC-12609]: Document the extension to vector syntax to support pre filtering: MB-62230 Fleshing out the text following review. Tidied up the advantages list. * [DOC-12609]: Document the extension to vector syntax to support pre-filtering: MB-62230 Fixups following review. * [DOC-12609] Capella - Fix up the documentation for Server to apply to Capella implementation of Vector Search. Changed filename for example since it's no longer a REST API example Added more details to search-request-params for filter object --------- Co-authored-by: Sarah Welton <[email protected]>
1 parent 9dda7c1 commit 9fcdd14

File tree

6 files changed

+96
-3
lines changed

6 files changed

+96
-3
lines changed

modules/search/examples/run-search-full-request.jsonc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@
5252
"ivf_max_codes_pct": 0.2
5353
},
5454
"field": "vector_field",
55-
"vector": [ 0.707106781186548, 0, 0.707106781186548 ]
55+
"vector": [ 0.707106781186548, 0, 0.707106781186548 ],
56+
"filter": {
57+
"min": 10000,
58+
"field": "id"
59+
}
5660
}
5761
],
5862
// end::knn[]

modules/search/pages/search-request-params.adoc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,13 @@ The Search Service uses the similarity metric defined in the xref:search-index-p
227227

228228
NOTE: The vector in your Search query must match the dimension of the vectors stored in your Search index.
229229
If the dimensions do not match, your Search query does not return any results.
230-
For more information about the dimension value, see the xref:search-index-params.adoc#dims[dims property] or the xref:type-mapping-options.adoc#dimension[Dimension option] in the UI.
230+
For more information about the dimension value, see the xref:search-index-params.adoc#dims[dims property] or the xref:type-mapping-options.adoc#dimension[Dimension option] in the UI.
231+
232+
|[[filter]]filter |Object |No a|
233+
234+
Add a filter object to xref:vector-search:pre-filtering-vector-search.adoc[add pre-filtering], based on an additional query, to a Vector Search query.
235+
236+
The `filter` object can take properties from any of the query types supported by the <<query-object,>>.
231237
|====
232238

233239
[#knn-params]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"fields": ["*"],
3+
"query": {
4+
"min": 70,
5+
"max": 80,
6+
"inclusive_min": false,
7+
"inclusive_max": true,
8+
"field": "brightness"
9+
},
10+
"knn": [
11+
{
12+
"k": 10,
13+
"field": "colorvect_l2",
14+
"vector": [ 176, 0, 176 ],
15+
"filter": {
16+
"field": "color",
17+
"match": "navy"
18+
}
19+
}
20+
]
21+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
= Pre-filtering Vector Searches
2+
:page-topic-type: guide
3+
:page-ui-name: {ui-name}
4+
:description: You can specify filters as part of a Vector Search query object to restrict the documents searched in a Search index.
5+
6+
[abstract]
7+
{description}
8+
9+
== About Pre-filtering
10+
11+
Using pre-filtering as part of your vector search offers two key advantages:
12+
13+
. *Enhanced precision and relevance:*
14+
Narrow your search results based on specific criteria, such as organization, date/time ranges, or geospatial locations.
15+
16+
. *Performance optimization:*
17+
Reduce the search space before executing queries to improve query execution time and reduce computational overhead.
18+
19+
== Prerequisites
20+
21+
* You have the Search Service enabled on a node in your operational cluster.
22+
For more information about how to change Services on your operational cluster, see xref:cloud:clusters:modify-database.adoc[].
23+
24+
* You have a bucket with scopes and collections in your operational cluster.
25+
For more information, see xref:cloud:clusters:data-service/manage-buckets.adoc[].
26+
27+
* You have created a Vector Search index.
28+
+
29+
For more information about how to create a Vector Search index, see xref:create-vector-search-index-ui.adoc[].
30+
+
31+
[TIP]
32+
--
33+
include::partial$download-sample-partial.adoc[]
34+
35+
For the best results, consider using the sample Vector Search index from xref:create-vector-search-index-ui.adoc#example[Create a Vector Search Index with the {page-ui-name}].
36+
--
37+
38+
== Procedure
39+
40+
To add pre-filtering to a Vector Search query:
41+
42+
. On the *Operational Clusters* page, select the operational cluster where you created your Search index.
43+
. Go to menu:Data Tools[Search].
44+
. Next to your Vector Search index, click btn:[Search].
45+
. In the *Search* field, enter a search query that includes a `filter` object with your `knn` object.
46+
+
47+
For more information about the `filter` object, see xref:search:search-request-params.adoc#filter[filter].
48+
. Press kbd:[Enter] or click btn:[Search].
49+
. (Optional) To view a document and its source collection, click a document name in the search results list.
50+
51+
=== Example: Pre-Filter A Vector Search Query For The Color "Navy"
52+
53+
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`.
54+
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`:
55+
56+
[source, json]
57+
----
58+
include::example$run-pre-filtered-vector-search-ui.json[]
59+
----
60+
61+

modules/vector-search/pages/run-vector-search-ui.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To run a Vector Search with the {page-ui-name}:
3636
. Next to your Vector Search index, click btn:[Search].
3737
. In the *Search* field, enter a search query.
3838
. Press kbd:[Enter] or click btn:[Search].
39-
. . (Optional) To view a document and its source collection, click a document name in the search results list.
39+
. (Optional) To view a document and its source collection, click a document name in the search results list.
4040

4141
[#similarity]
4242
=== Example: Running a Simple Vector Similarity Query
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* xref:cloud:vector-search:vector-search.adoc[]
22
** xref:cloud:vector-search:create-vector-search-index-ui.adoc[]
3+
** xref:cloud:vector-search:pre-filtering-vector-search.adoc[]
34
** xref:cloud:vector-search:run-vector-search-ui.adoc[]
45
** xref:cloud:vector-search:run-vector-search-sdk.adoc[]
56
** xref:cloud:vector-search:fine-tune-vector-search.adoc[]

0 commit comments

Comments
 (0)