Query variable scalability and performance

I, too, have stumbled upon this problem, which I call filtering based on nested node value.

I tried to decompose the problem, and this is what I came up with:

  • let’s assume, you have the Dictionary as a PREDICATE, you can then @filter(eq(shortName, "value")) which is indexed and efficient.
  • we have it however as a NODE, but unfortunately there is no @filter(eq(dict.shortName, "value")) as far as I am aware
  • this can be somehow simulated with cascade. Below I have made an equivalent query to yours, using cascade directive; however I’m not sure, how efficient cascades are. I think they’re better than filtering based on huge uid lists, but I’d love to have a better alternative to dealing with this use case
query dentry($dict: string){
  DICT as var(func: eq(shortName, $dict))

  dentry(func: allofterms(content, "apple")) @cascade {
    content
	dict @filter(uid(DICT))
    meaning {
	  dict @filter(uid(DICT))
      translation {
	    dict @filter(uid(DICT))
        content
      }
    }
  }
}
1 Like