|
1 | 1 | = Pre-filtering Vector Searches |
2 | 2 | :page-topic-type: guide |
3 | 3 | :page-ui-name: {ui-name} |
4 | | -:description: You can specify filters as part of a vector search statement which will restrict the documents searched during the query. |
| 4 | +:description: You can specify filters as part of a Vector Search query object to restrict the documents searched in a Search index. |
5 | 5 |
|
6 | 6 | [abstract] |
7 | 7 | {description} |
@@ -42,26 +42,28 @@ For the best results, consider using the sample Vector Search index from xref:cr |
42 | 42 |
|
43 | 43 | == Procedure |
44 | 44 |
|
45 | | -To run a pre-filtered vector search with the REST API: |
| 45 | +To add pre-filtering to a Vector Search with the REST API: |
46 | 46 |
|
47 | 47 | . In your command-line tool, enter a `curl` command with the `XPOST` verb. |
48 | 48 | . Set your header content to include `"Content-Type: application/json"`. |
49 | 49 | . Add your `username`, `password`, and the Search Service endpoint on port `8094`. |
50 | 50 | . Add the `index name` you want to query to the endpoint. |
51 | | - |
| 51 | ++ |
52 | 52 | [source, console] |
53 | 53 | ---- |
54 | 54 | curl -XPOST -H "Content-Type: application/json" \ |
55 | 55 | -u ${CB_USERNAME}:${CB_PASSWORD} http://${CB_HOSTNAME}:8094/api/bucket/vector-sample/scope/color/index/{INDEX_NAME}/query \ |
56 | 56 | -d \ |
57 | 57 | ---- |
| 58 | +. Enter a search query that includes a `filter` object with your `knn` object. |
| 59 | ++ |
| 60 | +For more information about the `filter` object, see xref:search:search-request-params.adoc#filter[filter]. |
| 61 | + |
58 | 62 |
|
59 | | -=== Example |
| 63 | +=== Example: Pre-Filter A Vector Search Query For The Color "Navy" |
60 | 64 |
|
61 | | -In the following example, you will extend a search query |
62 | | -to find matches in `color-index`. |
63 | | - A pre-filter on the query will narrow the documents in the index searched to those with a `color` field value |
64 | | - that closely matches `navy`. |
| 65 | +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`. |
| 66 | +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`: |
65 | 67 |
|
66 | 68 | [source, console] |
67 | 69 | ---- |
|
0 commit comments