将SQL查询转换为Neo4j

时间:2019-02-27 15:29:11

标签: sql neo4j

我正在尝试将以下SQL查询转换为Neo4j,但无法弄清楚如何处理Neo4j中的嵌入式查询。

SQL查询为:

Code: stack=1, locals=3, args_size=1 0: ldc #2 // String lo 2: astore_1 3: aload_1 4: invokedynamic #3, 0 // InvokeDynamic #0:makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String; 9: astore_2 10: return

此查询基本上提取研究人员的h-index。为此,我首先需要输入每个作者的所有论文及其引用的数量(论文)。这对应于第一个“ aux”查询,我在Neo4j中将其写为:

with aux as ( -- Amount of citations
    select p.id, p.scientist_id, p.title, count(*) as citations
  from paper p join citation c2 on (p.id = c2.paper_id)
  group by 1,2,3 )
select id, name, min(h) as h_index from (
  select c.id,
         c.name,
         aux1.title,
         aux1.citations,
         -- Replacing the use of analytical functions
         -- Eq. to: count(*) over (parition by c.id order by p.citations desc)
         ( select count(*) from aux aux2
           where aux2.citations >= aux1.citations
             and aux2.scientist_id = aux1.scientist_id) as h
  from scientist c join aux aux1 on (c.id = aux1.scientist_id)
) where h >= citations
group by id, name;

如您所见,我已经在Neo4j中获得了aux子句,但是我不知道如何继续执行SQL select来提取h的最终数量。

非常感谢您的帮助!

0 个答案:

没有答案