I was filtering multiple properties and fetching a node, so if had multiple filter
joined with and
and or
. 2 work fine but from the 3rd it seems to crash.
Below is a simplified demonstration of the error.
With filter
gremlin> g.V().filter(has("name", "marko"))
==>v[1]
gremlin> g.V().filter(has("name", "marko")).and().filter(has("name", "marko"))
==>v[1]
gremlin> g.V().filter(has("name", "marko")).and().filter(has("name", "marko")).and().filter(has("name", "marko"))
java.util.ConcurrentModificationException
Type ':help' or ':h' for help.
Display stack trace? [yN]
Without filter
gremlin> g.V().has("name", "marko")
==>v[1]
gremlin> g.V().has("name", "marko").and().has("name", "marko")
==>v[1]
gremlin> g.V().has("name", "marko").and().has("name", "marko").and().has("name", "marko")
java.util.ConcurrentModificationException
Type ':help' or ':h' for help.
Display stack trace? [yN]
dummy-name
is something that does not exist. still crashes with a different error
gremlin> g.V().hasLabel("dummy-name").filter(has("name", "a").or().has("name", "b").or().has("name", "c"))
java.lang.ArrayIndexOutOfBoundsException
Type ':help' or ':h' for help.
Display stack trace? [yN]y
java.lang.ArrayIndexOutOfBoundsException
when connecting to NEO4J and using filter
it throws me
test_gremlin.py", line 49, in execut_final_query
results = future_results.result()
File "/usr/lib/python3.6/concurrent/futures/_base.py", line 432, in result
return self.__get_result()
File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/home/admin-12/.local/lib/python3.6/site-packages/gremlin_python/driver/resultset.py", line 81, in cb
f.result()
File "/usr/lib/python3.6/concurrent/futures/_base.py", line 425, in result
return self.__get_result()
File "/usr/lib/python3.6/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/admin-12/.local/lib/python3.6/site-packages/gremlin_python/driver/connection.py", line 77, in _receive
self._protocol.data_received(data, self._results)
File "/home/admin-12/.local/lib/python3.6/site-packages/gremlin_python/driver/protocol.py", line 106, in data_received
"{0}: {1}".format(status_code, data["status"]["message"]))
gremlin_python.driver.protocol.GremlinServerError: 597: None
Am I writing the wrong query? or is this a bug?
Version: Gremlin 3.3.1
I don't know why multiple and()
conditions don't work offhand, though I suppose they should, so I created an issue in JIRA for that: TINKERPOP-2029
This does work however:
gremlin> g.V().and(filter(has("name", "marko")), filter(has("name", "marko")), filter(has("name", "marko")))
==>v[1]
or more simply:
gremlin> g.V().and(has("name", "marko"), has("name", "marko"), has("name", "marko"))
==>v[1]
In your comment on the question you wrote that you want to really do a
and b
or c
and d
- that seems possible with this approach:
gremlin> g.V().or(and(has('name','marko'),has('age',29)),and(has('name','josh'),has('age',32)))
==>v[1]
==>v[4]
or in this case more simply as:
gremlin> g.V().or(has('name','marko').has('age',29),has('name','josh').has('age',32))
==>v[1]
==>v[4]