Skip to content

Commit 2edee91

Browse files
committed
Correct vector-search doc to match current behavior
Address review feedback on PR opensearch-project#5363: - filter_type=omitted section: describe the actual path (native DSL, then ScriptQueryBuilder fallback executed server-side, and only then in-memory evaluation when predicate translation itself fails), not "falls back to in-memory" as the general case. - Limitations: GROUP BY / aggregations are actively rejected by VectorSearchIndexScanBuilder.pushDownAggregation, not merely "not validated". Add outer-WHERE-on-subquery rejection, which is also enforced by the same scan builder's validatePlan walker. Signed-off-by: Eric Wei <mengwei.eric@gmail.com>
1 parent 3396772 commit 2edee91

1 file changed

Lines changed: 20 additions & 12 deletions

File tree

docs/user/dql/vector-search.rst

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,18 @@ Two placement strategies are available via the ``filter_type`` option:
158158

159159
Behavior depends on whether ``filter_type`` is specified:
160160

161-
- **Omitted** — pushdown is attempted using the ``post`` placement. If the
162-
``WHERE`` clause cannot be translated to an OpenSearch filter (for example,
163-
it contains an expression that requires in-memory evaluation), the engine
164-
falls back to evaluating the predicate in memory. A query with no ``WHERE``
165-
clause is valid.
161+
- **Omitted** — pushdown is attempted using the ``post`` placement.
162+
Predicates that translate to native OpenSearch queries are pushed down as a
163+
``bool.filter`` alongside the k-NN query. Predicates that do not have a
164+
native equivalent (for example, arithmetic or function calls on indexed
165+
fields) are pushed down as an OpenSearch script query and evaluated
166+
server-side. Only when predicate translation itself fails does the engine
167+
fall back to evaluating the ``WHERE`` clause in memory after the k-NN
168+
results are returned. A query with no ``WHERE`` clause is valid.
166169
- **Explicit (``post`` or ``efficient``)** — a ``WHERE`` clause is required,
167-
and it must be fully translatable to an OpenSearch filter. If the ``WHERE``
168-
clause is missing or cannot be translated, the query fails with a
169-
descriptive error. This applies to both ``post`` and ``efficient``.
170+
and it must be translatable to an OpenSearch filter query. If the
171+
``WHERE`` clause is missing or cannot be translated, the query fails with
172+
a descriptive error. This applies to both ``post`` and ``efficient``.
170173
Specifying ``filter_type=post`` explicitly is useful when you want the
171174
query to fail fast rather than silently fall back to in-memory filtering.
172175

@@ -222,11 +225,16 @@ Scoring, sorting, and limits
222225
Limitations
223226
===========
224227

225-
The following are not part of the ``vectorSearch()`` preview contract and
226-
should be avoided:
228+
The following shapes are outside the ``vectorSearch()`` preview contract:
227229

228-
- ``GROUP BY`` and aggregations over a ``vectorSearch()`` relation are not
229-
validated.
230+
- ``GROUP BY`` and aggregations over a ``vectorSearch()`` relation are
231+
rejected with an error.
232+
- An outer ``WHERE`` clause applied to a ``vectorSearch()`` subquery is
233+
rejected with an error, because the predicate would be evaluated only
234+
after the top-k rows have been selected by vector distance and can
235+
silently yield zero rows. Place the predicate inside the subquery,
236+
directly on the ``vectorSearch()`` alias, so it can participate in
237+
``WHERE`` pushdown.
230238
- ``JOIN`` between a ``vectorSearch()`` relation and another relation is
231239
not validated.
232240
- ``UNION`` / ``INTERSECT`` / ``EXCEPT`` combining a ``vectorSearch()``

0 commit comments

Comments
 (0)