Filter by property equal not working as expected on string

Description

Filtering by equal on a text property seems to result in a “contains” filter instead.

Example:

from weaviate.classes.query import Filter
from weaviate.connect import ConnectionParams
from weaviate import WeaviateClient

weaviate_client = WeaviateClient(
    connection_params=ConnectionParams.from_url(      
        os.getenv("WEAVIATE_SERVER_URL","http://localhost:8080"),  
        int(os.getenv("WEAVIATE_SERVER_GRPC_PORT", 50051))    
))

col = weaviate_client.collections.use(index)
response = col.query.fetch_objects(filters=Filter.by_property(“drillDiameter”).equal(“2 mm”),limit=3)

for o in response.objects:
    print(o.properties[‘drillDiameter’])

outputs:

2,4 mm
2,1 mm
5,2 mm

Server Setup Information

  • Weaviate Server Version: 1.30.2
  • Deployment Method: local Docker run semitechnologies/weaviate:1.30.2
  • Multi Node? Number of Running Nodes: default settings
  • Client Language and Version: weaviate-client 4.16.10 (python, poetry-installed)
  • Multitenancy?: default settings

Is this a known bug or may it be related to my specific test case or setup? I couldn’t find anything about this yet, any help would be much appreciated.

Hi!
The tokenization property has an impact on the filtering process. What tokenization are you using?
You can read more about it here - Tokenization and filters | Weaviate Documentation

2 Likes

That’s right! Thanks @Bigdwarf43 !

So when you index 2 mm using word tokenization (default) you end up with two tokens: 2 and mm.

If you set the tokenization to field, you will then get a token with 2 mm

Happy coding!

1 Like