Skip to content

Commit 81de316

Browse files
authored
Merge pull request #1905 from weaviate/object_ttl_params
TTL parameter name proposals
2 parents 8a4cc5a + e2e0230 commit 81de316

File tree

4 files changed

+29
-29
lines changed

4 files changed

+29
-29
lines changed

integration/test_collection_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,7 +1842,7 @@ def test_object_ttl_creation(collection_factory: CollectionFactory) -> None:
18421842
collection = collection_factory(
18431843
object_ttl=Configure.ObjectTTL.delete_by_creation_time(
18441844
time_to_live=datetime.timedelta(days=30),
1845-
post_search_filter=True,
1845+
filter_expired_objects=True,
18461846
),
18471847
inverted_index_config=Configure.inverted_index(index_timestamps=True),
18481848
)
@@ -1861,15 +1861,15 @@ def test_object_ttl_update(collection_factory: CollectionFactory) -> None:
18611861
collection = collection_factory(
18621862
object_ttl=Configure.ObjectTTL.delete_by_update_time(
18631863
time_to_live=datetime.timedelta(days=30),
1864-
post_search_filter=True,
1864+
filter_expired_objects=True,
18651865
),
18661866
inverted_index_config=Configure.inverted_index(index_timestamps=True),
18671867
)
18681868

18691869
config = collection.config.get()
18701870
assert config.object_ttl_config is not None
18711871
assert config.object_ttl_config.delete_on == "updateTime"
1872-
assert config.object_ttl_config.post_search_filter
1872+
assert config.object_ttl_config.filter_expired_objects
18731873
assert config.object_ttl_config.time_to_live == datetime.timedelta(days=30)
18741874

18751875

@@ -1881,7 +1881,7 @@ def test_object_ttl_custom(collection_factory: CollectionFactory) -> None:
18811881
collection = collection_factory(
18821882
properties=[wvc.config.Property(name="customDate", data_type=DataType.DATE)],
18831883
object_ttl=Configure.ObjectTTL.delete_by_date_property(
1884-
date_property="customDate", post_search_filter=False, time_to_live_after_date=-1
1884+
property_name="customDate", filter_expired_objects=False, ttl_offset=-1
18851885
),
18861886
inverted_index_config=Configure.inverted_index(index_timestamps=True),
18871887
)
@@ -1890,4 +1890,4 @@ def test_object_ttl_custom(collection_factory: CollectionFactory) -> None:
18901890
assert config.object_ttl_config is not None
18911891
assert config.object_ttl_config.delete_on == "customDate"
18921892
assert config.object_ttl_config.time_to_live == datetime.timedelta(seconds=-1)
1893-
assert not config.object_ttl_config.post_search_filter
1893+
assert not config.object_ttl_config.filter_expired_objects

weaviate/collections/classes/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,7 +1712,7 @@ def to_dict(self) -> Dict:
17121712
class _ObjectTTLConfig(_ConfigBase):
17131713
enabled: bool
17141714
time_to_live: Optional[datetime.timedelta]
1715-
post_search_filter: bool
1715+
filter_expired_objects: bool
17161716
delete_on: Union[str, Literal["updateTime"], Literal["creationTime"]]
17171717

17181718

weaviate/collections/classes/config_methods.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ def _get_object_ttl_config(schema: Dict[str, Any]) -> Optional[_ObjectTTLConfig]
396396
return _ObjectTTLConfig(
397397
enabled=True,
398398
delete_on=delete_on,
399-
post_search_filter=schema["objectTtlConfig"]["postSearchFilter"],
399+
filter_expired_objects=schema["objectTtlConfig"]["filterExpiredObjects"],
400400
time_to_live=time_to_live,
401401
)
402402
else:

weaviate/collections/classes/config_object_ttl.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class _ObjectTTLCreate(_ConfigCreateModel):
88
enabled: bool = True
9-
postSearchFilter: Optional[bool]
9+
filterExpiredObjects: Optional[bool]
1010
deleteOn: Optional[str]
1111
defaultTtl: Optional[int]
1212

@@ -17,60 +17,60 @@ class _ObjectTTL:
1717
@staticmethod
1818
def delete_by_update_time(
1919
time_to_live: int | datetime.timedelta,
20-
post_search_filter: Optional[bool] = None,
20+
filter_expired_objects: Optional[bool] = None,
2121
) -> _ObjectTTLCreate:
2222
"""Create an `ObjectTimeToLiveConfig` object to be used when defining the object time-to-live configuration of Weaviate.
2323
2424
Args:
25-
time_to_live: The time-to-live for objects in seconds.
26-
post_search_filter: If enabled search results will be filtered to remove expired objects that have not yet been deleted.
25+
time_to_live: The time-to-live for objects in relation to their last update time (seconds). Must be positive.
26+
filter_expired_objects: If enabled, exclude expired but not deleted objects from search results.
2727
"""
2828
if isinstance(time_to_live, datetime.timedelta):
2929
time_to_live = int(time_to_live.total_seconds())
3030
return _ObjectTTLCreate(
3131
deleteOn="_lastUpdateTimeUnix",
32-
postSearchFilter=post_search_filter,
32+
filterExpiredObjects=filter_expired_objects,
3333
defaultTtl=time_to_live,
3434
)
3535

3636
@staticmethod
3737
def delete_by_creation_time(
3838
time_to_live: int | datetime.timedelta,
39-
post_search_filter: Optional[bool] = None,
39+
filter_expired_objects: Optional[bool] = None,
4040
) -> _ObjectTTLCreate:
4141
"""Create an `ObjectTimeToLiveConfig` object to be used when defining the object time-to-live configuration of Weaviate.
4242
4343
Args:
44-
time_to_live: The time-to-live for objects in seconds. Must be a positive value.
45-
post_search_filter: If enabled search results will be filtered to remove expired objects that have not yet been deleted.
44+
time_to_live: The time-to-live for objects in relation to their creation time (seconds). Must be positive.
45+
filter_expired_objects: If enabled, exclude expired but not deleted objects from search results.
4646
"""
4747
if isinstance(time_to_live, datetime.timedelta):
4848
time_to_live = int(time_to_live.total_seconds())
4949
return _ObjectTTLCreate(
5050
deleteOn="_creationTimeUnix",
51-
postSearchFilter=post_search_filter,
51+
filterExpiredObjects=filter_expired_objects,
5252
defaultTtl=time_to_live,
5353
)
5454

5555
@staticmethod
5656
def delete_by_date_property(
57-
date_property: str,
58-
time_to_live_after_date: Optional[int | datetime.timedelta] = None,
59-
post_search_filter: Optional[bool] = None,
57+
property_name: str,
58+
ttl_offset: Optional[int | datetime.timedelta] = None,
59+
filter_expired_objects: Optional[bool] = None,
6060
) -> _ObjectTTLCreate:
6161
"""Create an Object ttl config for a custom date property.
6262
6363
Args:
64-
date_property: The name of the date property to use for object expiration.
65-
time_to_live_after_date: The time-to-live for objects in seconds after the date property value. Can be negative
66-
post_search_filter: If enabled search results will be filtered to remove expired objects that have not yet been deleted.
64+
property_name: The name of the date property to use for object expiration.
65+
ttl_offset: The time-to-live for objects relative to the date (seconds if integer). Can be negative for indicating that objects should expire before the date property value.
66+
filter_expired_objects: If enabled, exclude expired but not deleted objects from search results.
6767
"""
68-
if isinstance(time_to_live_after_date, datetime.timedelta):
69-
time_to_live_after_date = int(time_to_live_after_date.total_seconds())
70-
if time_to_live_after_date is None:
71-
time_to_live_after_date = 0
68+
if isinstance(ttl_offset, datetime.timedelta):
69+
ttl_offset = int(ttl_offset.total_seconds())
70+
if ttl_offset is None:
71+
ttl_offset = 0
7272
return _ObjectTTLCreate(
73-
deleteOn=date_property,
74-
postSearchFilter=post_search_filter,
75-
defaultTtl=time_to_live_after_date,
73+
deleteOn=property_name,
74+
filterExpiredObjects=filter_expired_objects,
75+
defaultTtl=ttl_offset,
7676
)

0 commit comments

Comments
 (0)