Skip to content

Commit

Permalink
Merge pull request #1159 from weaviate/range_filterable
Browse files Browse the repository at this point in the history
Add support for range filters
  • Loading branch information
dirkkul authored Jul 4, 2024
2 parents a09598b + 954af1c commit c60e2f6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ env:
WEAVIATE_123: 1.23.15
WEAVIATE_124: 1.24.19
WEAVIATE_125: 1.25.5
WEAVIATE_126: 1.26.0-rc.0

WEAVIATE_126: preview-range-roaring-set-index-rename-indexrangeble-to-indexrangefilters-1083432

jobs:
lint-and-format:
Expand Down
40 changes: 35 additions & 5 deletions integration/test_collection_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,10 @@ def test_collection_config_empty(collection_factory: CollectionFactory) -> None:
assert config.vector_index_config.ef == -1
assert config.vector_index_config.ef_construction == 128
assert config.vector_index_config.flat_search_cutoff == 40000
assert config.vector_index_config.max_connections == 64
if collection._connection._weaviate_version.is_lower_than(1, 26, 0):
assert config.vector_index_config.max_connections == 64
else:
assert config.vector_index_config.max_connections == 32
assert config.vector_index_config.quantizer is None
assert config.vector_index_config.skip is False
assert config.vector_index_config.vector_cache_max_objects == 1000000000000
Expand Down Expand Up @@ -203,7 +206,10 @@ def test_collection_config_defaults(collection_factory: CollectionFactory) -> No
assert config.vector_index_config.ef == -1
assert config.vector_index_config.ef_construction == 128
assert config.vector_index_config.flat_search_cutoff == 40000
assert config.vector_index_config.max_connections == 64
if collection._connection._weaviate_version.is_lower_than(1, 26, 0):
assert config.vector_index_config.max_connections == 64
else:
assert config.vector_index_config.max_connections == 32
assert config.vector_index_config.quantizer is None
assert config.vector_index_config.skip is False
assert config.vector_index_config.vector_cache_max_objects == 1000000000000
Expand Down Expand Up @@ -432,7 +438,10 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None
assert config.vector_index_config.ef == -1
assert config.vector_index_config.ef_construction == 128
assert config.vector_index_config.flat_search_cutoff == 40000
assert config.vector_index_config.max_connections == 64
if collection._connection._weaviate_version.is_lower_than(1, 26, 0):
assert config.vector_index_config.max_connections == 64
else:
assert config.vector_index_config.max_connections == 32
assert config.vector_index_config.quantizer.bit_compression is False
assert config.vector_index_config.quantizer.centroids == 128
assert config.vector_index_config.quantizer.encoder.type_ == PQEncoderType.TILE
Expand Down Expand Up @@ -492,7 +501,10 @@ def test_collection_config_update(collection_factory: CollectionFactory) -> None
assert config.vector_index_config.ef == -1
assert config.vector_index_config.ef_construction == 128
assert config.vector_index_config.flat_search_cutoff == 40000
assert config.vector_index_config.max_connections == 64
if collection._connection._weaviate_version.is_lower_than(1, 26, 0):
assert config.vector_index_config.max_connections == 64
else:
assert config.vector_index_config.max_connections == 32
assert config.vector_index_config.quantizer is None
assert config.vector_index_config.skip is False
assert config.vector_index_config.vector_cache_max_objects == 2000000
Expand Down Expand Up @@ -826,7 +838,10 @@ def test_config_skip_vector_index(collection_factory: CollectionFactory) -> None
assert config.vector_index_config.ef == -1
assert config.vector_index_config.ef_construction == 128
assert config.vector_index_config.flat_search_cutoff == 40000
assert config.vector_index_config.max_connections == 64
if collection._connection._weaviate_version.is_lower_than(1, 26, 0):
assert config.vector_index_config.max_connections == 64
else:
assert config.vector_index_config.max_connections == 32
assert config.vector_index_config.quantizer is None
assert config.vector_index_config.skip is True
assert config.vector_index_config.vector_cache_max_objects == 1000000000000
Expand Down Expand Up @@ -1029,3 +1044,18 @@ def test_create_custom_vectorizer_named(collection_factory: CollectionFactory) -
assert len(config.vector_config) == 1
assert config.vector_config["name"].vectorizer.vectorizer == "text2vec-contextionary"
assert config.vector_config["name"].vectorizer.model == {"vectorizeClassName": False}


@pytest.mark.parametrize("index_range_filters", [True, False])
def test_range_filters(collection_factory: CollectionFactory, index_range_filters: bool) -> None:
collection_dummy = collection_factory("dummy")
if collection_dummy._connection._weaviate_version.is_lower_than(1, 26, 0):
pytest.skip("range filters are not supported in Weaviate versions lower than 1.26.0")

collection = collection_factory(
properties=[
Property(name="text", data_type=DataType.INT, index_range_filters=index_range_filters)
],
)
config = collection.config.get()
assert config.properties[0].index_range_filters == index_range_filters
4 changes: 4 additions & 0 deletions weaviate/collections/classes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,7 @@ def to_dict(self) -> Dict[str, Any]:
class _Property(_PropertyBase):
data_type: DataType
index_filterable: bool
index_range_filters: bool
index_searchable: bool
nested_properties: Optional[List[NestedProperty]]
tokenization: Optional[Tokenization]
Expand Down Expand Up @@ -1481,6 +1482,8 @@ class Property(_ConfigCreateModel):
A description of the property.
`index_filterable`
Whether the property should be filterable in the inverted index.
`index_range_filters`
Whether the property should support range filters in the inverted index.
`index_searchable`
Whether the property should be searchable in the inverted index.
`nested_properties`
Expand All @@ -1498,6 +1501,7 @@ class Property(_ConfigCreateModel):
description: Optional[str] = Field(default=None)
indexFilterable: Optional[bool] = Field(default=None, alias="index_filterable")
indexSearchable: Optional[bool] = Field(default=None, alias="index_searchable")
indexRangeFilters: Optional[bool] = Field(default=None, alias="index_range_filters")
nestedProperties: Optional[Union["Property", List["Property"]]] = Field(
default=None, alias="nested_properties"
)
Expand Down
1 change: 1 addition & 0 deletions weaviate/collections/classes/config_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ def _properties_from_config(schema: Dict[str, Any]) -> List[_Property]:
data_type=DataType(prop["dataType"][0]),
description=prop.get("description"),
index_filterable=prop["indexFilterable"],
index_range_filters=prop.get("indexRangeFilters", False),
index_searchable=prop["indexSearchable"],
name=prop["name"],
nested_properties=(
Expand Down

0 comments on commit c60e2f6

Please sign in to comment.