diff --git a/lib/collection/src/problems/unindexed_field.rs b/lib/collection/src/problems/unindexed_field.rs index fc0ad9f8f6..4ece7c428f 100644 --- a/lib/collection/src/problems/unindexed_field.rs +++ b/lib/collection/src/problems/unindexed_field.rs @@ -743,7 +743,9 @@ mod tests { infer_index_from_field_condition(&condition), vec![FieldIndexType::KeywordMatch], ); - // A text index is not enough: it holds tokens, not raw values. + // A text index holds tokens, not raw values, so it cannot serve the + // condition and does not satisfy strict mode. Without strict mode the + // condition still runs through the payload fallback. let text = PayloadFieldSchema::FieldType(PayloadSchemaType::Text); assert!(!schema_capabilities(&text).contains(&FieldIndexType::KeywordMatch)); } diff --git a/tests/openapi/test_substring_match.py b/tests/openapi/test_substring_match.py index 3ada3d4889..04aeb0cf43 100644 --- a/tests/openapi/test_substring_match.py +++ b/tests/openapi/test_substring_match.py @@ -155,13 +155,23 @@ def test_substring_match_count(): # --------------------------------------------------------------------------- -# 3. Strict mode: substring filtering requires a keyword index. A text -# index is not enough, since it stores tokens rather than raw values. +# 3. A text index on the field cannot serve substring (it stores tokens, not +# raw values), so the condition falls back to the payload scan and still +# works. Only strict mode may reject it. +# --------------------------------------------------------------------------- + +def test_substring_match_with_text_index_falls_back(): + _create_index("description", "text") + for substring in SUBSTRING_PROBES: + assert _scroll_ids(_substring_filter("description", substring)) == expected_ids(substring), substring + + +# --------------------------------------------------------------------------- +# 4. Strict mode: substring filtering requires a keyword index. A text +# index does not count, since it cannot serve the condition. # --------------------------------------------------------------------------- def test_strict_mode_requires_keyword_index(): - _create_index("description", "text") - _set_strict_mode({ "enabled": True, "unindexed_filtering_retrieve": False,