I tried your code.
Is there a small mistake in your code?
b = client.collections.create(
"a",
properties=[
Property(name="field1", data_type=DataType.INT),
Property(name="field2", data_type=DataType.INT),
],
)
should it be like this?
b = client.collections.create(
"b",
properties=[
Property(name="field1", data_type=DataType.INT),
Property(name="field2", data_type=DataType.INT),
],
)
your example did work as expect but if I change the filter to like this:
client.collections.delete(["a", "b", ])
b = client.collections.create(
"b",
properties=[
Property(name="field1", data_type=DataType.INT),
Property(name="field2", data_type=DataType.INT),
],
)
a = client.collections.create(
name="a", references=[ReferenceProperty(name="has_b", target_collection=b.name)]
)
b1 = b.data.insert(properties={"field1": 1, "field2": 2})
b2 = b.data.insert(properties={"field1": 3, "field2": 4})
b3 = b.data.insert(properties={"field1": 1, "field2": 3})
b4 = b.data.insert(properties={"field1": 2, "field2": 4})
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("field1").equal(1)
& Filter.by_ref("has_b").by_property("field2").equal(4),
).objects
print(objects)
print(len(objects))
there should be no b object with field1==1 and field2==4, but the result is like:
[Object(uuid=_WeaviateUUIDInt('795f9ef0-76c6-4e8e-9113-91933f442ddf'), metadata=MetadataReturn(creation_time=None, last_update_time=None, distance=None, certainty=None, score=None, explain_score=None, is_consistent=None, rerank_score=None), properties={}, references=None, vector=None, collection='A'), Object(uuid=_WeaviateUUIDInt('864c1bce-5354-4fd3-b7ea-0627f74ae5cb'), metadata=MetadataReturn(creation_time=None, last_update_time=None, distance=None, certainty=None, score=None, explain_score=None, is_consistent=None, rerank_score=None), properties={}, references=None, vector=None, collection='A')]
2