Regular expressions require the
trigram index. A trigram is a substring of 3 consecutive characters, or runes.
The trigrams of trigram are: tri, rig, igr, gra and ram.
Valid regular expressions are able to be converted to a trigram query against the index. Dgraph searches the trigram index for possible matches and then runs the full regular expression against the possibles.
Each regular expressions must match at least one trigram.
It’s a good idea to think carefully about regular expression queries. The more possible trigrams matched by a query, the more results are checked against the full regular expression and the less efficient the query. The reverse, however, is also true. The more trigrams enforced by the regular expression, the better use Dgraph can make of the index and the smaller the possible results set.
Thus, writing efficient regular expressions generally means making use of long substrings and avoiding as much alternate choice as possible.
i may follow the final
/ to indicate case insensitive search.
Natalie Portman is the only actor in our database who has acted in an alien movie and has the word alien embedded in her name.