我正在过滤多个属性并获取一个节点,因此如果有多个filter
与and
和or
联接在一起。 2个工作正常,但从第3个开始似乎崩溃了。
下面是该错误的简化说明。
使用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]
没有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
是不存在的。仍然因其他错误而崩溃
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
连接到NEO4J并使用filter
时,它会抛出我
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
我写错了查询吗?还是这个错误?
版本:Gremlin 3.3.1
答案 0 :(得分:2)
我不知道为什么多个and()
条件不能立即生效,尽管我想应该可以,所以我在JIRA中为此创建了一个问题:TINKERPOP-2029
这确实起作用:
gremlin> g.V().and(filter(has("name", "marko")), filter(has("name", "marko")), filter(has("name", "marko")))
==>v[1]
或更简单地说:
gremlin> g.V().and(has("name", "marko"), has("name", "marko"), has("name", "marko"))
==>v[1]
在您对所写问题的评论中,您实际上想做a
和b
或c
和d
-这种方法似乎可以实现:>
gremlin> g.V().or(and(has('name','marko'),has('age',29)),and(has('name','josh'),has('age',32)))
==>v[1]
==>v[4]
,或者在这种情况下更简单地表示为:
gremlin> g.V().or(has('name','marko').has('age',29),has('name','josh').has('age',32))
==>v[1]
==>v[4]