Search code examples
neo4jspring-data-neo4jneo4j-ogm

Neo4j OGM - filters combination


I need to form a dynamic query, using Filter/Filters in neo4j-ogm. The simplified version of the query may look like this:

(A and B and C)
  and (
     (
      (D or E) and not (F or J)
     )  
      or
     (
      (H or I) and not (G or K)
     ) 
     or
    ...... more conditions like this
    )

)

I cannot find how to do it using Filters by combining them into logical structures (am I looking not hard enough?).

Is it possible (from implementation looks like Filters are internally maintained as a plain List, which does not allow any precedence etc)?


Solution

  • Looks like this is not possible with current version. I ended up 'flatting' the conditions tree into a structure like this:

    A and B and C and D and not F and not J or 
    A and B and C and E and not F and not J or 
    A and B and C and H and not G and not K or 
    A and B and C and I and not G and not K
    
    

    This is rather ugly and unreadable for debugging purposes, but With AND having precedence over OR, should work.