HAS_REFINEMENTS computes whether a particular attribute has non-implicit refinements in the current navigation state.
HAS_REFINEMENTS function is:
HAS_REFINEMENTS(<attribute>)
where attribute is a Dgraph attribute (of any data type) in a collection.In particular, HAS_REFINEMENTS determines if a specific attribute has the same value for every record in a group. If so, then the attribute should be able to return actual refinement values.
Return values
HAS_REFINEMENTS return behavior is:
HAS_REFINEMENTS returns NULL.HAS_REFINEMENTS returns FALSE.HAS_REFINEMENTS returns TRUE.HAS_REFINEMENTS return behavior is:
HAS_REFINEMENTS returns FALSE. This includes the in which attribute is the empty set for all rows in the group.HAS_REFINEMENTS returns TRUE.Note that although HAS_REFINEMENTS tells you if a particular attribute has non-implicit refinements, it does not tell you what they actually are nor does it actually return the refinement values.
HAS_REFINEMENTS example
HAS_REFINEMENTS is used to determine whether the ACCT_FIRM attribute has available refinements:
RETURN Result AS SELECT HAS_REFINEMENTS(ACCT_FIRM) AS Refs FROM CorpData GROUP
In this case, the query returns true, which means that the attribute has available non-implicit refinements.
Treating empty sets like NULLs
HAS_REFINEMENTS to treat empty sets like NULLs, then you can add a per-aggregate WHERE clause to the HAS_REFINEMENTS aggregator, as in this example (x is a multi-assign attribute):
RETURN Result AS SELECT HAS_REFINEMENTS(x) WHERE (x IS NOT EMPTY) AS Refs FROM CorpData GROUP
HAS_REFINEMENTS return behavior is:
HAS_REFINEMENTS(x) WHERE (x IS NOT EMPTY) is NULL.HAS_REFINEMENTS(x) WHERE (x IS NOT EMPTY) is FALSE.HAS_REFINEMENTS(x) WHERE (x IS NOT EMPTY) is TRUE.For more information on per-aggregate WHERE clauses, see Per-aggregation filters.