cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! Site migration is underway. Phase 1: replicate users.

Search with multiple criteria and nested conditions

madiskou
Graph Buddy

Hello,
I have to write a query, that search nodes with multiple criteria and i need help to do it, for now i have 3 criteria (lists of string) and i do like this :

WITH 
    ['a1','a2'] AS appsList,  
    ['p1'] AS publishersList,  
    ['e1','e2'] as eventTypeList,  
    ['env1', 'env2'] AS envList
CALL apoc.do.when(  
    size(publishersList)>0,  
    'MATCH p=(event:event)<-[:event]-(nodes) WHERE ANY(x IN labels(event) WHERE x IN eventTypeList) AND event.publisher IN publishersList RETURN nodes',  
    'MATCH p=(event:event)<-[:event]-(nodes) WHERE ANY(x IN labels(event) WHERE x IN eventTypeList) RETURN nodes',  
    {publishersList:publishersList, eventTypeList:eventTypeList}  
)  
YIELD value 
WITH value.nodes as n,collect(value.nodes) as nodes, envList
CALL apoc.do.when(  
    size(envList)>0,  
    "MATCH (n) WHERE n.environment IN envList RETURN n",
    "RETURN n",  
    {envList:envList, n:n}  
  ) YIELD value
with collect(value.n) as nodes2, nodes
with apoc.coll.intersection(nodes, nodes2) as interests_intersection 
return interests_intersection

I don't know if it is the right way to do this kind of query search with criteria, for now i have 3 criteria but i will have annothers and i don't know if perf will be good ?
what i want is :

if criteria 1 ...
    if criteria 2 ....
       if criteria 3 ...
             .
             . 
             .
       else 
    else
else
return

Thank you for helping

1 REPLY 1

Cobra
Ninja
Ninja

Hello @madiskou

What is the data model (labels, types and properties)?
What are the criteria? Labels, types or properties?
Do you want to search on the whole graph?

Regards,
Cobra