# Filtering date range does not work (combining dates in where clause)

**URL:** <https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323>\
**Category:** Support\
**Tags:** bug\
**Created:** [January 29, 2024, 4:16pm UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323 "2024-01-29T16:16:30Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![klt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/klt/32/884_2.png) [@klt](https://forum.weaviate.io/u/klt)\
**Post date:** [January 29, 2024, 4:16pm UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/1 "2024-01-29T16:16:30Z")

</div>

We just upgraded from weaviate 1.15 to the latest version of weaviate (unsure if that is related) but some queries do not work anymore.

We are conducting a search in weaviate, which used to work **and still works locally in our dev environment** :

```auto
const request = client.graphql
    .get()
    .withClassName("TextChunk")
    .withFields(
      `
    document_id,
    lines,
    document {
      ... on Document {
        upload_time
      }
    }`
    )
    .withBm25({ query: text.toLowerCase(), properties: ["lines"] })
    .withWhere({
      operator: "And",
      operands: [
        {
          path: ["document", "Document", "upload_time"],
          operator: "GreaterThanEqual",
          valueDate: startDate.toISOString(),
        },
        {
          path: ["document", "Document", "upload_time"],
          operator: "LessThanEqual",
          valueDate: endDate.toISOString(),
        },
      ],
    })

```

The query works when removing both or one of the operands. That also means that both operands individually still work. Only the combination using “and” does not work anymore and returns 0 results. We are sure there are results for the given dates and search terms in the db.

What we tried:  
Nothing which we tried seemed to be a reasonable cause for the problem as the operators individually still work.  
However we noticed we had some duplicate Docs and the TextChunks then were referencing two Docs. So we deleted all duplicate Docs now. No results.  
We also noticed we had some TextChunks that referenced Docs that dont exist anymore, so the Upload\_time in this query was null. We create the Docs and added the upload time. Again - no effect.

We do not get any errors so at this point we cannot do any further debugging.

---

<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:** [February 2, 2024, 12:55pm UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/2 "2024-02-02T12:55:09Z")

</div>

Hi @klt ! Sorry for the late response here ☹

I would try reindexing this in a new cluster or new class, and check if it will solve.

The fact that works on your development, may indicate that some indexing may be twisted.

You can reindex your data from a new cluster (or even from one class to a new one) using this as a guide:

> **[Migrate data | Weaviate - Vector Database](https://weaviate.io/developers/weaviate/manage-data/migrate)**
>
> Overview

Let me know if that helps 🙂

---

<div class="post-metadata">

**Author:** ![klt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/klt/32/884_2.png) [@klt](https://forum.weaviate.io/u/klt)\
**Post date:** [February 5, 2024, 2:29pm UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/3 "2024-02-05T14:29:32Z")

</div>

Will try! Thanks for the suggestion

---

<div class="post-metadata">

**Author:** ![klt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/klt/32/884_2.png) [@klt](https://forum.weaviate.io/u/klt)\
**Post date:** [February 6, 2024, 12:28pm UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/4 "2024-02-06T12:28:39Z")

</div>

Hi @DudaNogueira,

so we tried duplicating the Document collection, because that is the collection that stores the date. However after doing that, we noticed that the query with AND does work on the Document collection itself, only not when resolving the Reference from TextChunk to Document.

So obviously rebuilding the index for the Document collection does not solve the issue.

Do you have any idea what we could do to resolve this? Delete and create the references again? Or would the be a way to build all indexes again? A bit clueless here.

Thank you!

---

<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:** [February 7, 2024, 7:23pm UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/5 "2024-02-07T19:23:02Z")

</div>

Oh.

The fact that it was giving different results in 2 different servers with the same data could be an index issue.

I believe this is similar to this thread:

> [@Possible bug when use greater\_or\_equal and less\_or\_equal with text](https://forum.weaviate.io/t/possible-bug-when-use-greater-or-equal-and-less-or-equal-with-text/1370):
>
> 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")…

Your filter basically says:

> fetch me objects from \*\* TextChunk\*\* that have references with \*\* upload\_time \>=X\*\* _while simultaneously_ having references with \*\* upload\_time \<=Y\*\* "

Let me know if this clarifies.

Thanks!

---

<div class="post-metadata">

**Author:** ![Markus\_Vogel](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/markus_vogel/32/969_2.png) [@Markus\_Vogel](https://forum.weaviate.io/u/Markus_Vogel)\
**Post date:** [February 13, 2024, 9:15am UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/6 "2024-02-13T09:15:01Z")

</div>

Hey @DudaNogueira, jumping in here as another one of the devs working on the same project as @klt.

I believe we have another issue here than the one you are referencing, because we did ensure that each TextChunk is only ever linked to a single Document. So a TextChunk that has a reference with **upload\_time \>= X** while simultaneously having a reference with **upload\_time \<= Y** should actually only be true if **X \<= upload\_time \<= Y** on that single linked Document. Now we did also ensure that we have object in our database that do match this query, but we do not get any results.

---

<div class="post-metadata">

**Author:** ![klt](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.weaviate.io/klt/32/884_2.png) [@klt](https://forum.weaviate.io/u/klt)\
**Post date:** [February 28, 2024, 9:25am UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/7 "2024-02-28T09:25:09Z")

</div>

Hey, any new ideas on this? We could not make any progress with this issue in a month now…

---

<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:** [February 28, 2024, 8:41pm UTC](https://forum.weaviate.io/t/filtering-date-range-does-not-work-combining-dates-in-where-clause/1323/8 "2024-02-28T20:41:37Z")

</div>

Hi!

Sorry for the delay here. I have escalated this to our engineers.

Thanks!
