I’m reading through some of the interactive tour.
Source: Query Variables in another query block II | Blocksvars | Dgraph Tour
Why not do: func: eq(name@en, "Taraji Henson")
instead?
Hey @gorillastanley,
eq() is a function which is used for exact matching. While alloftherms() looks if all the terms are present in the target predicate in any order.
For example: If you have a mutation like
_:a <name> "peter parker" .
then
q(func: eq(name, "parker peter")){
name
}
it will return blank response while the following will return node with name "peter parker,
q(func: allofterms(name, "parker peter")){
name
}
Hope it clarifies your doubt. Feel free to bring up followup questions.
1 Like
Thanks for your response! I guess in that specific example though, it’d be better style to use eq with the exact name of the director?
Yes, eq could have been used but that’s somewhat debatable . I guess
allofterms()
was used for two purposes:
- The director’s name could have contained middle name, or could have been in “lastname firstname” format, so we do not want exact matching.
- Demonstrate the
allofterms()
function, so the user can quickly go to the docs and learn about it.
1 Like
Thanks again! That makes sense.
1 Like