# Strange hehavior when combine filters with and operator to filter by reference

**URL:** <https://forum.weaviate.io/t/strange-hehavior-when-combine-filters-with-and-operator-to-filter-by-reference/1677>\
**Category:** General\
**Created:** [March 11, 2024, 12:14pm UTC](https://forum.weaviate.io/t/strange-hehavior-when-combine-filters-with-and-operator-to-filter-by-reference/1677 "2024-03-11T12:14:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadowlin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shadowlin/32/800_2.png) [@shadowlin](https://forum.weaviate.io/u/shadowlin)\
**Post date:** [March 11, 2024, 12:14pm UTC](https://forum.weaviate.io/t/strange-hehavior-when-combine-filters-with-and-operator-to-filter-by-reference/1677/1 "2024-03-11T12:14:00Z")

</div>

I have a filter like this

```auto
        text_chunk_filter = (
                Filter.by_ref("has_index_in_file_data").by_property("file_data_uuid").equal(file_data_uuid)
                & Filter.by_ref("has_index_in_file_data").by_property("index").greater_or_equal(start_index)
                & Filter.by_ref("has_index_in_file_data").by_property("index").less_or_equal(end_index)
        )

```

this will cause a warning:

```auto
{"level":"warning","msg":"Number of found nested reference results exceeds configured QUERY_MAXIMUM_RESULTS. This may result in search performance degradation or even out of memory errors.","nested_reference_results":11922,"query_maximum_results":10000,"time":"2024-03-11T12:09:04Z"}

```

I have already kinda know what the warning is and trying to solve it but I find a strange thing.  
if I use this filter the then the warning will not be triggered

```auto
        text_chunk_filter = (
                Filter.by_ref("has_index_in_file_data").by_property("file_data_uuid").equal(file_data_uuid)
        )

```

As far As I know ther former filter should be more strict than the later one but how could the later one won’t trigger the warning?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [March 11, 2024, 7:30pm UTC](https://forum.weaviate.io/t/strange-hehavior-when-combine-filters-with-and-operator-to-filter-by-reference/1677/2 "2024-03-11T19:30:11Z")

</div>

Hi @shadowlin !

that `text_chunk_filter` is the only part it changes on that query? the returned properties and references are the same for both, right?

Also, how is that query being made? hybrid?

Thanks!

---

<div class="post-metadata">

**Author:** ![shadowlin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shadowlin/32/800_2.png) [@shadowlin](https://forum.weaviate.io/u/shadowlin)\
**Post date:** [March 12, 2024, 1:22am UTC](https://forum.weaviate.io/t/strange-hehavior-when-combine-filters-with-and-operator-to-filter-by-reference/1677/3 "2024-03-12T01:22:46Z")

</div>

yes.The filter is the only thing changed. the query is a vector only query.  
And the “file\_data\_uuid” filter alone could reduce the returned result to blow 100 objects.  
I always find the filter1 & filter2 dosen’t work as I thought in weaviate, is there something I missed?

---

<div class="post-metadata">

**Author:** ![DudaNogueira](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/dudanogueira/32/7846_2.png) [@DudaNogueira](https://forum.weaviate.io/u/DudaNogueira)\
**Post date:** [March 13, 2024, 9:12pm UTC](https://forum.weaviate.io/t/strange-hehavior-when-combine-filters-with-and-operator-to-filter-by-reference/1677/4 "2024-03-13T21:12:25Z")

</div>

Hi!

Do you think you could reproduce this on a smaller scale and with anonymous data?

I tried some options here, but always got the correct results with my dataset.

Here is a nice variation:

```auto
from weaviate import classes as wvc

include_weather = True
include_plane = True

base_filter = wvc.query.Filter.by_property("category").equal("ANIMALS")
weather_filter = wvc.query.Filter.by_property("question").like("weather")
plane_filter = wvc.query.Filter.by_property("question").like("plane")

used_filters = [base_filter]
if include_plane:
    used_filters.append(plane_filter)
if include_weather:
    used_filters.append(weather_filter)

query = questions.query.fetch_objects(
    filters=wvc.query.Filter.any_of(used_filters) # can also be all_of
)
for object in query.objects:
    print(object.properties)

```

---

<div class="post-metadata">

**Author:** ![shadowlin](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/shadowlin/32/800_2.png) [@shadowlin](https://forum.weaviate.io/u/shadowlin)\
**Post date:** [March 14, 2024, 1:31am UTC](https://forum.weaviate.io/t/strange-hehavior-when-combine-filters-with-and-operator-to-filter-by-reference/1677/5 "2024-03-14T01:31:32Z")

</div>

I will try to come up with a demo to show the case later.
