I am trying to do a query where I have multiple boolean operations to be done but can't figure out how to do it.
The query is something like (A and B) or (C and D)
I first tried
g.V()\
.has("attra", P.lte(20))\
.has("attrb", P.gte(10))\
.or_()\
.has("attrc", P.lte(20))\
.has("attrd", P.gte(10))
but it turns out anything after the or_()
in the query is or
ed and that is not what I want. Because I have other complex boolean logic down the line as well.
and I also tried
g.V()\
.or_(
has("attra", P.lte(20)).and().has("attrb", P.gte(10)),
has("attrc", P.lte(20)).and().has("attrd", P.gte(10))
)
but it says that has
is not defined. Is this how you do it? Where is this has even defined?
Help would be really appreciated
EDIT: I have the following imports in my file
from __future__ import print_function
from gremlin_python.structure.graph import Graph
from gremlin_python.process.strategies import *
from gremlin_python.process.traversal import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.graph_traversal import __ as AnonymousTraversal