Hi Ismael,
>
>
if I understand correctly, you want to find all documents which have a 
top-level attribute "carga" and either a sub-attribute "anual" or "diario", 
regardless of their value.

A simple query to achieve this would be as follows:

FOR doc IN ons
    FILTER doc.carga.diario != null OR doc.carga.anual != null
    RETURN doc


Documents without the attributes will have an implicit value of null and 
are eliminated by the FILTER.

Note that documents with an explicit null as attribute value will also be 
ignored. If you don't want that, you can use:

FOR doc IN ons
    FILTER HAS(doc, "carga")
    FILTER HAS(doc.carga, "diario") OR HAS(doc.carga, "anual")
    RETURN doc


The filter criteria could also be written as: FILTER HAS(...) AND ( 
HAS(...) OR HAS(...) )

If you want to test for many different sub-attributes or use a bind 
parameter to make this dynamic, you could make use of an array comparison 
operator 
<https://docs.arangodb.com/3.3/AQL/Operators.html#array-comparison-operators> 
like so:

FOR doc IN test
    FILTER ["diario", "anual"] ANY IN ATTRIBUTES(doc.carga)
    RETURN doc


The ATTRIBUTES() function 
<https://docs.arangodb.com/3.3/AQL/Functions/Document.html#attributes> is 
used to get all sub-attribute names of the carga object.
The ALL IN operator is used to test if any provided strings (here: diario 
or anual) is in that list.

Hope this helps!

-- 
You received this message because you are subscribed to the Google Groups 
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to arangodb+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to