Skip to content

Commit 0120c65

Browse files
committed
docs: state the coupled retokenization contract explicitly (#2098)
Documents on update_property_index that a tokenization change via the searchable index also retokenizes an existing filterable index as one coupled task (shared taskId) and thereby changes filter matching, with filterable as the target for bucket-only changes and cancellation applying to the whole task. Explains why PropertyIndexes.data_type is a plain str (primitives match the DataType enum, references carry the target collection name) and pins reference-property parsing with a mock test.
1 parent a64ec15 commit 0120c65

3 files changed

Lines changed: 47 additions & 0 deletions

File tree

mock_tests/test_property_reindex.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import weaviate
1010
from mock_tests.conftest import MOCK_IP, MOCK_PORT, MOCK_PORT_GRPC
1111
from weaviate.collections.classes.config import (
12+
DataType,
1213
PropertyIndexState,
1314
PropertyIndexTaskStatus,
1415
PropertyIndexType,
@@ -455,6 +456,43 @@ def test_delete_property_index_enum_and_literal_hit_same_route(
455456
weaviate_139_mock.check_assertions()
456457

457458

459+
def test_get_property_indexes_reference_property(
460+
weaviate_139_mock: HTTPServer, client_139: weaviate.WeaviateClient
461+
) -> None:
462+
"""Reference properties carry the target collection name as dataType and still parse."""
463+
weaviate_139_mock.expect_request(f"{SCHEMA_PATH}/indexes", method="GET").respond_with_json(
464+
{
465+
"collection": COLLECTION,
466+
"properties": [
467+
{
468+
"name": "title",
469+
"dataType": "text",
470+
"indexes": [{"type": "searchable", "status": "ready", "tokenization": "word"}],
471+
},
472+
{
473+
"name": "ofArticle",
474+
"dataType": "Article",
475+
"indexes": [{"type": "filterable", "status": "ready"}],
476+
},
477+
],
478+
}
479+
)
480+
481+
indexes = client_139.collections.use(COLLECTION).config.get_property_indexes()
482+
title, ref = indexes.properties
483+
# primitive values match the DataType str-enum
484+
assert title.data_type == DataType.TEXT
485+
# reference properties carry the qualified target collection name instead
486+
assert ref.name == "ofArticle"
487+
assert ref.data_type == "Article"
488+
assert ref.indexes[0].type == "filterable"
489+
490+
out = json.loads(json.dumps(indexes.to_dict()))
491+
assert out["properties"][1]["dataType"] == "Article"
492+
493+
weaviate_139_mock.check_assertions()
494+
495+
458496
def test_delete_property_index_surfaces_server_message(
459497
weaviate_139_mock: HTTPServer, client_139: weaviate.WeaviateClient
460498
) -> None:

weaviate/collections/classes/config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2281,6 +2281,9 @@ class _PropertyIndexStatus(_ConfigBase):
22812281
@dataclass
22822282
class _PropertyIndexes(_ConfigBase):
22832283
name: str
2284+
# For primitive properties the value matches the `DataType` str-enum (comparisons like
2285+
# `data_type == DataType.TEXT` work); reference properties instead carry the qualified
2286+
# target collection name (e.g. "Article"), which is why this is a plain str, not `DataType`.
22842287
data_type: str
22852288
description: Optional[str]
22862289
indexes: List[PropertyIndexStatus]

weaviate/collections/config/executor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,12 @@ def update_property_index(
790790
configuration. If the configuration already matches, no work is submitted and the returned
791791
task reports a `NO_OP` status. The server accepts at most one configuration change per request.
792792
793+
Caution: changing `tokenization` via the `searchable` index ALSO retokenizes the property's
794+
`filterable` index when one exists. Both indexes are migrated by a single coupled task (their
795+
status entries share one `taskId`), and the retokenization changes how filters match on that
796+
property. To retokenize only the filterable bucket, target the `filterable` index instead.
797+
Cancelling via either index type cancels the whole coupled task.
798+
793799
Args:
794800
property_name: The property whose index to create or migrate.
795801
index_name: The type of the index, a `PropertyIndexType` value or one of the literals

0 commit comments

Comments
 (0)