Possible bug when use greater_or_equal and less_or_equal with text

client: python client 4.4.rc1
weavite: 1.23.7

code to reproduce the bug

import weaviate
from weaviate.collections.classes.config import Property, DataType, ReferenceProperty
from weaviate.collections.classes.filters import Filter

from base_dependencies import load_config

client = weaviate.connect_to_custom(
    http_host=load_config("weaviate")["host"],
    http_port=load_config("weaviate")["http_port"],
    http_secure=False,
    grpc_host="localhost",
    grpc_port=load_config("weaviate")["grpc_port"],
    grpc_secure=False,
    auth_credentials=weaviate.auth.AuthApiKey(api_key=load_config("weaviate")["api_key"])
)

client.collections.delete(["a", "b", ])
b = client.collections.create(
    "b",
    properties=[
        Property(name="text", data_type=DataType.TEXT),
        Property(name="code", data_type=DataType.TEXT),
    ],
)
a = client.collections.create(
    name="a", references=[ReferenceProperty(name="has_b", target_collection=b.name)]
)

b1 = b.data.insert(properties={"text": "text1", "code": "1752871214070435840321"})
b2 = b.data.insert(properties={"text": "text2", "code": "1752871214070435840521"})
b3 = b.data.insert(properties={"text": "text3", "code": "1752871214070435840621"})
b4 = b.data.insert(properties={"text": "text4", "code": "1752871214070435840721"})

a1 = a.data.insert({}, references={"has_b": [b1, b2]})
a2 = a.data.insert({}, references={"has_b": [b3, b4]})

objects = a.query.fetch_objects(
    filters=Filter.by_ref("has_b").by_property("code").greater_or_equal("1752871214070435840326")
            & Filter.by_ref("has_b").by_property("code").less_or_equal("1752871214070435840327")
).objects

print(objects)
print(len(objects))

ssert len(objects) == 0

expect behavior:
should find no object since there is no b object with code fullfill the query condition but the code could find one.

Hi @shadowlin !

I tried this and got the same results :thinking:

And this doesn’t seem to be client related as I got the same from v3 and graphql:

import weaviate
client_v3 = weaviate.Client("http://localhost:8080")
q = client_v3.query.get("A", "name").with_where(
    {
        "operator": "And",
        "operands": [
            {
                "path": ["has_b", "B", "code"],
                "operator": "GreaterThanEqual",
                "valueText": "326",
            },
            {
                "path": ["has_b", "B", "code"],
                "operator": "LessThanEqual",
                "valueText": "327",
            },
        ]
    }
)
print(q.do())
print(q.build())

and the output:

{'data': {'Get': {'A': [{'name': 'a1'}]}}}
{Get{A(where: {operator: And operands: [{path: ["has_b", "B", "code"] operator: GreaterThanEqual valueText: "326"}, {path: ["has_b", "B", "code"] operator: LessThanEqual valueText: "327"}]} ){name}}}

I will check internally and will get back to you.

Thanks for pointing it out!

Hi Shadownlin!

What your filter is saying is:

fetch me objects from a that have references with code>=326 while simultaneously having references with code<=327"

On that case, a1 will indeed be the one that fulfill this creteria.

Let me know if this clarifies.

Thanks!

I don’t get it.
a1 has b1 and b2
b1.code = 1752871214070435840321
b2.code= 1752871214070435840521

the query condition is
1752871214070435840326<=has_b.code<=1752871214070435840327
while should only contain

  • 1752871214070435840326
  • 1752871214070435840327

I don’t think a1 should be found.

@DudaNogueira Could you review my last reply thanks