To use anyofterm you have to change the indexing to
name: string @index(exact, term) .
alloftext may be working for you because you may have changed the default (from example ‘name: string @index(exact) .’) to
name: string @index(exact, fulltext) .
I would recommend you use term indexing.
allofterms: Get started with Dgraph
alloftext: Get started with Dgraph
you can learn more about indexes using our tour: A Tour of Dgraph
Cheers