Reputation: 25862
I need to organize into the subsequent chain (1..N
calls) of apoc.index.in
function, something like this:
MATCH (d:Decision)-[:HAS_VALUE_ON]->(ch:Characteristic) WHERE ch.id = 10
CALL apoc.index.in(ch,'HAS_VALUE_ON','property.2.5:7 AND value:45') YIELD node AS decision
MATCH (decision)-[:HAS_VALUE_ON]->(ch:Characteristic) WHERE ch.id = 23
CALL apoc.index.in(ch,'HAS_VALUE_ON','property.1.8:326 OR property.4:17') YIELD node AS decision
MATCH (decision)-[:HAS_VALUE_ON]->(ch:Characteristic) WHERE ch.id = 19
CALL apoc.index.in(ch,'HAS_VALUE_ON','property.15.3:"mike" OR value:43') YIELD node AS decision
RETURN decision
As you may see I need to filter the set of Decision
based on different conditions described at apoc.index.in, for example like 'property.15.3:"mike" OR value:43'
and so on.
Right now the query above doesn't work. Is it possible with APOC to chain it and if so, could you please show an example.
Upvotes: 0
Views: 293
Reputation: 30417
You should be able to do this if you can send a list parameter that contains maps of values you plan to use. For example, provided a list parameter of:
inputs = [{chId:10, predicate:"property.2.5:7 AND value:45"}, {chId:23, predicate:"property.1.8:326 OR property.4:17"}, {chId:19, predicate:"property.15.3:'mike' OR value:43"}]
(you'll need to figure out the voodoo to escape the inner quotes around 'mike' properly given the language you're working with)
Then you could use the following query:
UNWIND $inputs as input
MATCH (ch:Characteristic)
WHERE ch.id = input.chId AND ()-[:HAS_VALUE_ON]->(ch)
CALL apoc.index.in(ch,'HAS_VALUE_ON', input.predicate) YIELD node AS decision
RETURN decision
Because of the UNWIND on the collection, each element of the collection will result in its own row, and the subsequent MATCH and CALL will be executed per row, so your decision results should contain any decision that meets the associated criteria.
Upvotes: 1