Bug in @filter() for day indexed edge

I think I found a weird quirk …

entryDate is a date, indexed on day.
status is a string representing open/closed etc. Indexed as exact.

q(func:eq(status,“new”) ) …

returns all the new entries. Good so far.

q(func:eq(status,“new”)) @filter(ge(entryDate, “2020-01-01”)) … returns nothing despite having entries.

q(func:eq(status,“new”)) @filter(ge(entryDate, “2019-01-01”)) … returns entries in 2019, but nothing in 2020.

q(func:ge(entryDate, “2020-01-01”)) @filter(eq(status,“new”)) … returns all entries since 1/1/2020 with a new status. Basically, what I would have expected from the first filtered query.

Am I missing something, or is this a bug in the date filter?

Thanks.
Mike

Please, share the results and the version you are using.

I don’t believe it could be a recent bug. Maybe you’re using some old version. But if so, if you provide a sample that could reproduce the bug. It would help a lot.

Sure - I’m on Dgraph version : v1.2.1

I’ve now found it on a couple of things, not just dates:

{
  q(func:type(Hours)) @filter(gt(hours.tracked,"2020-01-01")) {
    hours.tracked
  }
}

Returns …

{
  "data": {
    "q": []
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 137800,
      "processing_ns": 11714900,
      "encoding_ns": 16300,
      "assign_timestamp_ns": 2643200,
      "total_ns": 14972200
    },
    "txn": {
      "start_ts": 774724
    },
    "metrics": {
      "num_uids": {
        "dgraph.type": 0,
        "hours.tracked": 0
      }
    }
  }
}

But:

{
  q(func:gt(hours.tracked,"2020-01-01")) {
    hours.tracked
  }
}

Returns …

{
  "data": {
    "q": [
      {
        "hours.tracked": "2020-01-15T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-22T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-31T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-24T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-28T00:00:00Z"
      },
      {
        "hours.tracked": "2020-02-21T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-22T00:00:00Z"
      } ...

I have a type Hours:

type Hours {
	hours.annul
	hours.annulText
	hours.bill
	hours.billText
	hours.comment
	hours.created
	hours.hold
	hours.holdText
	hours.hours
	hours.id
	hours.query
	hours.queryText
	hours.status
	hours.tracked
	hours.updated
	employee
}

In which hours.tracked is a datetime indexed on day.

P.S. Exactly the same query but with 2019 …

{
 	q(func:type(Hours)) @filter(gt(hours.tracked,2019-01-01)){
      hours.tracked
  }
}

Returns

{
  "data": {
    "q": [
      {
        "hours.tracked": "2019-10-17T00:00:00Z"
      },
      {
        "hours.tracked": "2019-08-15T00:00:00Z"
      },
      {
        "hours.tracked": "2019-10-24T00:00:00Z"
      } ...

So it works for values less than 2020! As I said, weird. It’s taken me all day so far to get it down to that call. I have exported and then re-imported the data just in case it was an indexing issue. But that hasn’t helped.

And - I’ve tried quoted and unquoted dates.

And … the 2019 list stops at the end of 2019, so even though it’s picked up all the 2019 entries, none of the 2020 ones appear at the end of the list, even though they’re greater than 2019-01-01,

P.P.S. It’s not the type system either, from what I can see.

{
 	q(func:has(hours.tracked)) @filter(gt(hours.tracked,2019-01-01)){
      hours.tracked
  }
}

Gives:

{
  "data": {
    "q": [
      {
        "hours.tracked": "2019-10-17T00:00:00Z"
      },
      {
        "hours.tracked": "2019-10-24T00:00:00Z"
      },

Whereas:

{
 	q(func:has(hours.tracked)) @filter(gt(hours.tracked,2020-01-01)){
      hours.tracked
  }
}

Gives:

{
  "data": {
    "q": []
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 137500,
      "processing_ns": 28087400,
      "encoding_ns": 15600,
      "assign_timestamp_ns": 2130300,
      "total_ns": 30931800
    },
    "txn": {
      "start_ts": 774733
    },
    "metrics": {
      "num_uids": {
        "hours.tracked": 0
      }
    }
  }
}

Again, the 2019 query contains no 2020 entries.

In fact, look at the return from q0 and q1 in this:

{
  q0(func:has(hours.tracked),first:2) @filter(gt(hours.tracked,2019-01-01)){
      hours.tracked
  }
  q1(func:has(hours.tracked),first:2) @filter(gt(hours.tracked,2020-01-01)){
      hours.tracked
  }
 	q2(func:gt(hours.tracked,2019-01-01),first:2){
      hours.tracked
  }
 	q3(func:gt(hours.tracked,2020-01-01),first:2){
      hours.tracked
  }
}

Gives:

{
  "data": {
    "q0": [
      {
        "hours.tracked": "2019-10-17T00:00:00Z"
      },
      {
        "hours.tracked": "2019-10-24T00:00:00Z"
      }
    ],
    "q1": [],
    "q2": [
      {
        "hours.tracked": "2020-01-15T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-22T00:00:00Z"
      }
    ],
    "q3": [
      {
        "hours.tracked": "2020-01-15T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-22T00:00:00Z"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 365100,
      "processing_ns": 37904400,
      "encoding_ns": 39000,
      "assign_timestamp_ns": 2104500,
      "total_ns": 41061800
    },
    "txn": {
      "start_ts": 774739
    },
    "metrics": {
      "num_uids": {
        "hours.tracked": 8
      }
    }
  }
}

q0 has no 2020 entries, q1 nothing, q3 and q4 being what I would expect to get from q0 and q1.

Thank you, I will analyze carefully and see if old versions happen the same.

I was unable to reproduce the issue in the most recent version.

Just to test: Can you undo all datetime-related indexes? and then reindex them. If it works, we certainly have a bug somewhere.

Query

{
  q(func: has(entryDate), orderasc:entryDate) @filter(ge(entryDate,"2000-01-01") ) {
    count(uid)
    status
    entryDate
  }
}
# {
#   q(func: ge(entryDate,"2019-01-01"), orderasc:entryDate) {
#     uid
#     status
#     entryDate
#   }
# }

I have tested several combinations of the query above.

JSON sample

It has 200 nodes.

{
   "set": [
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-01-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-02-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-03-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-04-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2000-05-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-01-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-02-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-03-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-04-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2002-05-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-01-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-02-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-03-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-04-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2019-05-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-01-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-02-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-03-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-04-10"
      },
            {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-01"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-02"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-03"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-04"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-05"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-06"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-07"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-08"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-09"
      },
      {
         "dgraph.type": "Test",
         "status": "new",
         "entryDate": "2020-05-10"
      }
   ]
}

I thought it might be an index issue. Before I wrote the q0 … q4 query example, I dropped the entire DB and reimported from RDF.

I dropped the entire DB and reimported from RDF.

and? back to normal?

No - that was the last set of examples I sent with all 4 queries in the one block.

I found the issue. Raised the query on the forum.

Then thought some more. Thought it might be a bad index. Dropped the DB and then imported the RDF. Then ran the queries again. The last example (with q0 … q4) was an afterthought but it shows the problem nicely.

Ok. Dropped the indexes individually, added them back.

{
 	q0(func:has(hours.tracked),first:2) @filter(gt(hours.tracked,2019-01-01)){
      hours.tracked
  }
  q1(func:has(hours.tracked),first:2) @filter(gt(hours.tracked,2020-01-01)){
      hours.tracked
  }
 	q2(func:gt(hours.tracked,2019-01-01),first:2){
      hours.tracked
  }
 	q3(func:gt(hours.tracked,2020-01-01),first:2){
      hours.tracked
  }
}

Gives:

{
  "data": {
    "q0": [],
    "q1": [],
    "q2": [
      {
        "hours.tracked": "2020-01-15T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-22T00:00:00Z"
      }
    ],
    "q3": [
      {
        "hours.tracked": "2020-01-15T00:00:00Z"
      },
      {
        "hours.tracked": "2020-01-22T00:00:00Z"
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 317500,
      "processing_ns": 87251100,
      "encoding_ns": 39700,
      "assign_timestamp_ns": 3631000,
      "total_ns": 91706300
    },
    "txn": {
      "start_ts": 994740
    },
    "metrics": {
      "num_uids": {
        "hours.tracked": 4
      }
    }
  }
}

(Just for clarity, I only added the ‘first’ to be able to show the query without having massive amounts of data coming back. I’ve removed the ‘first:2’ in the queries and get the same result).

As I said, I was unable to reproduce. I tested on version v2.0.0-beta and v1.2.1 - they all had the same behavior as expected.

If you have a way to reproduce the problem with 100% accuracy. This would help a lot.

Other than sending you an RDF dump and seeing if you can reproduce, I’m not sure how best to show it - the examples I shared show the problem. I don’t want to package up RDFs into the public domain though.

In the meantime, I’ve worked around it by using var (func:gt(hours.tracked,2020-01-01)) and using uid() in a subsequent query. It’s nowhere near as efficient for the DB but does (seem to) work.