Dgraph DQL Tour



When Dgraph is searching for strings, dates, or other values based on a filter, it needs an index to make the search efficient. We’ve already seen examples of how to specify the indexes in a schema mutation.

int, float, geo and date have default indexes, but string has options of what index types to choose. Multiple indexes can be built for the same string valued predicate.

For string the following indexes are available

  • term (default) for use with allofterms and anyofterms
  • exact for use with inequality - matching whole string
  • hash as for exact but hashes string - useful with long strings
  • fulltext for full text search with alloftext and anyoftext
  • trigram for use with regular expressions

Multiple indexes are specified as arguments to @index.

Apply the schema mutation to add the indexes to the movie data. It will take a few minutes for Dgraph to compute those indexes for all the movie data. Let the mutation run and move on once it’s finished.

You might find Docker stops your Dgraph process during the mutation. That might be a memory issue - increase the amount of memory Docker allows and then restart Dgraph, load the initial schema and data, then apply this mutation.

6.1 Indexes