Filter with eq list argument behaves differently without index

Moved from GitHub dgraph/5767

Posted by danielmai:

What version of Dgraph are you using?

v20.03.3

Have you tried reproducing the issue with the latest release?

Yes

What is the hardware spec (RAM, OS)?

Ubuntu Linux, Docker

Steps to reproduce the issue (command/config used to run Dgraph).

  1. Run Dgraph cluster

  2. Set the following schema with a string predicate:

    curl 'localhost:8080/alter' \
         -d 'name: string .'
    
  3. Run the following mutation

    curl 'localhost:8080/mutate?commitNow=true' \
         -H "Content-Type: application/json" \
         -d '{"set":[{"uid":"_:root","connects":[{"name": "A"},{"name":"B"}]}]}'
    
  4. Run the following query

    curl 'localhost:8080/query' \
         -H "Content-Type: application/graphql+-" \
         -d '
    {
      q(func: has(connects)) {
        connects @filter(eq(name, ["A", "B"])) {
          name
        }
      }
    }'
    

Expected behaviour and actual result.

The actual query result is:

{
  "data": {
    "q": [
      {
        "connects": [
          {
            "name": "B"
          }
        ]
      }
    ]
  }
}

The expected query result is that eq(name, ["A", "B"]) in the filter returns back both nodes A and B in the response.

If I set an index on the name predicate, then the filter works as expected.

Alter schema:

name: string @index(hash) .

Query response:

{
  "data": {
    "q": [
      {
        "connects": [
          {
            "name": "A"
          },
          {
            "name": "B"
          }
        ]
      }
    ]
  }
}

danielmai commented :

Either the non-indexed behavior should align with the indexed behavior or we need to update the eq() docs to state that eq(predicate, [val1, val2, ..., valN]) only works with indexed predicates.