Neo4j - 无法从 "parent-child" 关系中获取所有记录

Neo4j - can't get all the records from a "parent-child" relationship

这是我的 类:

class Author
  include Neo4j::ActiveNode
  property :author_name,  type: String
  property :author_id,    type: Integer
  has_many :out, :wokas
end

class Woka
  include Neo4j::ActiveNode
  property :author_id,    type: Integer
  property :publisher_id, type: Integer
  property :language_id,  type: Integer
  property :woka_id,      type: Integer
  property :woka_title,   type: String
  has_one :in, :author
  has_one :in, :publisher
  has_one :in, :language
end

Woka 是 "child" 作者。

我正在从 RoR 执行这样的事情:

a = Author.find_by(author_name: 'Camus, Albert')
w = Woka.find_by(woka_title: 'Caligula')

第一个是正确的,只有一个作者。 第二个不是,因为很多作者都写过卡利古拉。

以下是上述两条语句的开发日志摘录:

 [36mCYPHER[0m [33m138ms[0m MATCH (n:`Author`) WHERE (n.author_name = {n_author_name}) RETURN n LIMIT {limit_1} | {:n_author_name=>"Camus, Albert", "limit_1"=>1}

 [36mCYPHER[0m [33m126ms[0m MATCH (n:`Woka`) WHERE (n.woka_title = {n_woka_title}) RETURN n LIMIT {limit_1} | {:n_woka_title=>"Caligula", "limit_1"=>1}

为什么"limit_1"=>1是由gem生成的?我没有要求对结果集做任何限制。

用密码写的查询returns正确的行数:31.

MATCH (w:Woka) WHERE (w.woka_title = 'Caligula') MATCH (a:Author)-[:AUTHORED]->(w:Woka) RETURN w.woka_id, w.woka_title as woka_title, a.author_name as author_name;

不知道这里有什么问题。

转述the documentation

find_by behaves as it does in ActiveRecord, returning the first object matching the criteria.

我认为您想改用这些语句,以获得所有可能的结果:

a = Author.all.where(author_name: 'Camus, Albert')
w = Woka.all.where(woka_title: 'Caligula')