First: You can not use a variable created in Query itself for The Query itself. You need to create a Query sequence as “pipe” in order to do sorting. Gives the error “used before definition”.
Second: Avoid using more than one “has” with the same predicate. You are using “has (billsType)” and “@filter (has (billsType))” - This has no effect whatsoever, it can delay in ms.
Third: See this query “Aggregation* Usage at other levels” at https://docs.dgraph.io/query-language/#aggregation - In it we have an usage similar to yours. It uses aggregation, variable propagation and sorting by variable.
If it still does not help, please provide a small mutation example according to its structure so that I can replicate here and offer you a better wayout. Can be in JSON tho.
The double use of “has” is due to an apparent bug where the uids of nodes that used to have the predicate, but have had that edge deleted, still turn up when doing a simple func: has(billType). I know the solution is hacky, but it works, and in fact it was suggested to me by you yourself right here:
As for the problem itself, I’m playing around with the best solution, my issue being finding a decent way to abstract it out enough to generate queries that can sort by such variables. Thanks to both of you for the links!
Heya! I’ve just upgraded dgraph and can confirm the phantom uids are no longer showing up. Thanks! I’ll be removing that superfluous filter from my searches now