Cannot create @id field with exact index


Report a GraphQL Bug

What edition and version of Dgraph are you using?

Edition:

  • SlashGraphQL
  • Dgraph (community edition/Dgraph Cloud)

If you are using the community edition or enterprise edition of Dgraph, please list the version:

Dgraph Version

Dgraph master and Dgraph v20.11.2 (latest)

master

$ dgraph version

Dgraph version   : v20.11.0-rc1-414-gf21ee367
Dgraph codename  : unnamed
Dgraph SHA-256   : f47c24e6bb5c05a7491f125b7d8f4b77b6337ed69acfc150c3c7189f30810db3
Commit SHA-1     : f21ee367
Commit timestamp : 2021-03-02 13:18:11 -0800
Branch           : master
Go version       : go1.15.5
jemalloc enabled : true

v20.11.2

Dgraph version   : v20.11.2
Dgraph codename  : tchalla-2
Dgraph SHA-256   : 0153cb8d3941ad5ad107e395b347e8d930a0b4ead6f4524521f7a525a9699167
Commit SHA-1     : 94f3a0430
Commit timestamp : 2021-02-23 13:07:17 +0530
Branch           : HEAD
Go version       : go1.15.5
jemalloc enabled : true

Have you tried reproducing the issue with the latest release?

Yes

Steps to reproduce the issue (paste the query/schema if possible)

Apply this GraphQL schema:

type Post {
    name: String! @id @search(by: [exact])
}

Expected behaviour and actual result.

Actual result: The schema update gives this error message:

resolving updateGQLSchema failed because input:2: Type Post; Field name: the arguments 'hash' and 'exact' can't be used together as arguments to @search.\n

Exact index is compatible with the @id functionality to maintain the uniqueness of the name field. So, I should be able to create an @id field and take advantage of the exact search functionality as well.

2 Likes

Hi @dmai , Thanks for creating this bug. We add hash index for predicate which have @id directive while converting schema to dgraph. That’s why , we are not able to add exact index on it.
I need to discuss it with team members whether it was design decision or it’s a bug, and if it’s a bug , will fix it soon.

This behavior is fixed and will be available in the 21.03 release.
Now, we overwrite the default hash index with the exact index for a field of type String! @id @search(by:[exact])
PR:fix(GRAPHQL): fix query rewriting for multiple order on nested field (#7523) by JatinDevDG · Pull Request #7536 · dgraph-io/dgraph · GitHub

1 Like