Querying an instance based on the values of all its related instances properties

Hi there,
I want to query an instance of a concept (concept-a) which has multiple relations to instances of concept-b.
The query should only return the instance of concept-a if the all the properties “is-active” of the related instances are true.
I’m not really getting it. Do you know how to implement the query?

    indication sub relation, relates condition, relates cause;

    concept-a sub entity,
        plays indication:cause,
        owns name;

    concept-b sub entity,
        plays indication:condition,
        owns name,
        owns is-active,

I can get all instances of concept-a where at least one related concept-b instance has an is-active state with true, but I want only those concept-a instances where every related concept-b instance has the is-active property set to true.

You could try a nested negation.

match
$a isa concept-a; 
not{
   (cause: $a, condition: $b) isa indication;
   not { $b has is-active true; }; 
};

Note that this will also match concept-a that aren’t part of any indication, and those related to concept-b without any is-active attributes.

Thank you @krishnan for your answer!
I tried your solution and it doesn’t work for me.
It basically gave me the same result as my solution which was this:

match
    $a isa concept-a, has name $n;
    ($a $b) isa indication;
    $b has is-active true; 
    get $a, $n;

I thought about grouping and counting in the query. But I don’t know how to find all nodes connected to concept-a with a specific relation. Do you think that’s even possible?

Krishnan’s query should be a bit different to yours:
Yours conceptually does: find a such that there is any indication b that has is-active = true
Krishnan’s query conceptually does: find a concept a that does not have any indication b which doesn’t have an is-active = true… in other words, find the a’s for which all b’s have is-active = true (or there are no bs [which also conforms to your requirement], or there are only b’s with no is-actives at all [which also conforms to your requirement])

Can you show some example data where Krishnan’s query does not work?

insert $a isa concept-a, has name "Fault A"; 
insert $a isa concept-a, has name "Fault B";

insert $b isa concept-b, has name "Condition A", has is-active true;
insert $b isa concept-b, has name "Condition B", has is-active true;
insert $b isa concept-b, has name "Condition C", has is-active true;
insert $b isa concept-b, has name "Condition D", has is-active false;


match $a isa concept-a, has name "Fault A"; $b isa concept-b, has name "Condition A"; insert (condition: $b, cause: $a) isa indication;
match $a isa concept-a, has name "Fault A"; $b isa concept-b, has name "Condition B"; insert (condition: $b, cause: $a) isa indication;
match $a isa concept-a, has name "Fault B"; $b isa concept-b, has name "Condition C"; insert (condition: $b, cause: $a) isa indication;
match $a isa concept-a, has name "Fault B"; $b isa concept-b, has name "Condition D"; insert (condition: $b, cause: $a) isa indication;

Here is some example data.
What I want to achieve is to get only the instance with the name Fault A, because both connected nodes have the property is active true. But with @krishnan’s query I also get the other one, that has one is-active true.

Edit: What I must say is that I don’t get any results without a is-active property set to true, what is pretty good, but I cannot figure out how to eliminate the concepts which don’t have alle connected conditions active.

Strange.
With this data, I only get Fault A for the query I posted.

I’m sorry @krishnan you’re totally right. Your solution works with the schema and data provided.
I obfuscated the real schema and tried to apply your solution to my schema and it didn’t work.
But it worked when I tried the example with the data here.
Maybe I made a mistake translating the query to my “real” schema. I will try to fix that and maybe come back, if I don’t get it running. Thank you so much for helping me out!

That was the error on my side, in my translated data I had a concept-b where without any is-active attribute. Thank you for the help.