Skip to content

Commit c2609c7

Browse files
authored
Vector indexes support filtering (#791)
1 parent 4b7ab17 commit c2609c7

File tree

4 files changed

+62
-4
lines changed

4 files changed

+62
-4
lines changed

site/content/3.12/aql/functions/vector.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,23 @@ be found depends on the data as well as the search effort (see the `nProbe` opti
5656
{{< info >}}
5757
- If there is more than one suitable vector index over the same attribute, it is
5858
undefined which one is selected.
59-
- You cannot have any `FILTER` operation between `FOR` and `LIMIT` for
60-
pre-filtering.
59+
60+
- In v3.12.4 and v3.12.5, you cannot have any `FILTER` operation between `FOR`
61+
and `LIMIT` for pre-filtering. From v3.12.6 onward, you can add `FILTER`
62+
operations between `FOR` and `SORT` that are then applied during the lookup in
63+
the vector index. Example:
64+
65+
```aql
66+
FOR doc IN coll
67+
FILTER doc.val > 3
68+
SORT APPROX_NEAR_COSINE(doc.vector, @q) DESC
69+
LIMIT 5
70+
RETURN doc
71+
```
72+
73+
Note that e.g. `LIMIT 5` does not ensure that you get 5 results by searching
74+
as many neighboring Voronoi cells as necessary, but it rather considers only as
75+
many as configured via the `nProbes` parameter.
6176
{{< /info >}}
6277

6378
### APPROX_NEAR_COSINE()

site/content/3.12/release-notes/version-3.12/whats-new-in-3-12.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,20 @@ has been added.
14831483

14841484
<small>Introduced in: v3.12.6</small>
14851485

1486+
Vector indexes now support filtering. You can add `FILTER` operations between
1487+
`FOR` and `SORT` that are then applied during the lookup in the vector index.
1488+
Note that e.g. `LIMIT 5` does not ensure that you get 5 results by searching
1489+
as many neighboring Voronoi cells as necessary, but it rather considers only as
1490+
many as configured via the `nProbes` parameter. Example:
1491+
1492+
```aql
1493+
FOR doc IN coll
1494+
FILTER doc.val > 3
1495+
SORT APPROX_NEAR_COSINE(doc.vector, @q) DESC
1496+
LIMIT 5
1497+
RETURN doc
1498+
```
1499+
14861500
Vector indexes can now be sparse to exclude documents with the embedding attribute
14871501
for indexing missing or set to `null`.
14881502

site/content/3.13/aql/functions/vector.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,23 @@ be found depends on the data as well as the search effort (see the `nProbe` opti
5656
{{< info >}}
5757
- If there is more than one suitable vector index over the same attribute, it is
5858
undefined which one is selected.
59-
- You cannot have any `FILTER` operation between `FOR` and `LIMIT` for
60-
pre-filtering.
59+
60+
- In v3.12.4 and v3.12.5, you cannot have any `FILTER` operation between `FOR`
61+
and `LIMIT` for pre-filtering. From v3.12.6 onward, you can add `FILTER`
62+
operations between `FOR` and `SORT` that are then applied during the lookup in
63+
the vector index. Example:
64+
65+
```aql
66+
FOR doc IN coll
67+
FILTER doc.val > 3
68+
SORT APPROX_NEAR_COSINE(doc.vector, @q) DESC
69+
LIMIT 5
70+
RETURN doc
71+
```
72+
73+
Note that e.g. `LIMIT 5` does not ensure that you get 5 results by searching
74+
as many neighboring Voronoi cells as necessary, but it rather considers only as
75+
many as configured via the `nProbes` parameter.
6176
{{< /info >}}
6277

6378
### APPROX_NEAR_COSINE()

site/content/3.13/release-notes/version-3.12/whats-new-in-3-12.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,6 +1483,20 @@ has been added.
14831483

14841484
<small>Introduced in: v3.12.6</small>
14851485

1486+
Vector indexes now support filtering. You can add `FILTER` operations between
1487+
`FOR` and `SORT` that are then applied during the lookup in the vector index.
1488+
Note that e.g. `LIMIT 5` does not ensure that you get 5 results by searching
1489+
as many neighboring Voronoi cells as necessary, but it rather considers only as
1490+
many as configured via the `nProbes` parameter. Example:
1491+
1492+
```aql
1493+
FOR doc IN coll
1494+
FILTER doc.val > 3
1495+
SORT APPROX_NEAR_COSINE(doc.vector, @q) DESC
1496+
LIMIT 5
1497+
RETURN doc
1498+
```
1499+
14861500
Vector indexes can now be sparse to exclude documents with the embedding attribute
14871501
for indexing missing or set to `null`.
14881502

0 commit comments

Comments
 (0)