neovis.js 2.1.0版与neo4j 5.12.0版不兼容吗?

nnt7mjpx  于 12个月前  发布在  其他
关注(0)|答案(3)|浏览(367)

我使用的是neovis.js 2.1.0版和neo4j 5.12.0版。当我尝试根据示例访问时,neo4j服务器返回以下错误:

Neo4jError: The property existence syntax `... exists(variable.property)` is no longer supported. Please use `variable.property IS NOT NULL` instead. (line 1, column 17 (offset: 16))
"MATCH (n) WHERE exists(n.pagerank)"

这些版本之间是否存在已知的不兼容性?
我的vue3.js代码如下:

<template>
  <h3>graph demo</h3>
  <div id="graph"></div>
</template>

<script setup>
import NeoVis from "neovis.js";
import { onMounted } from "vue";

const config = ref({
  containerId: "graph",
  neo4j: {
    serverUrl: "bolt://localhost:7687",
    serverUser: "neo4j",
    serverPassword: "neo4j_password",
  },
  labels: {},
  relationships: {},
  initialCypher: "MATCH (n) return n",
});

nMounted(() => {
  const vis = new NeoVis(config);
  vis.render();
});
</script>

<style scoped></style>
hc2pp10m

hc2pp10m1#

exists从Neo4j 5.0起已更改为仅检查图形模式是否存在,而不是属性。
neovis.js必须使用这个变体:

MATCH (n) WHERE n.pagerank IS NOT NULL

注意:你可以阅读exists for Neo4j 4.4的文档,它确实也可以处理属性。

5cnsuln7

5cnsuln72#

Neovis.js源代码在defaults.ts中包含以下片段:

neo4j: {
    initialQuery: `MATCH (n) WHERE exists(n.pagerank)
                    WITH (n), RAND() AS random
                    ORDER BY random LIMIT 3000
                    OPTIONAL MATCH (n)-[r]-(m)
                    //WITH n,r,m WHERE exists(n.pagerank) AND exists(m.pagerank) AND exists(m.community)
                    RETURN n, r, m;`,
    ...

这似乎是你的错误的原因。您可能需要为此创建an issue

nhhxz33t

nhhxz33t3#

谢谢你的帮助。
Neovis.js与Neo4j 5.12.0兼容,除了一些过时的语法,如上面提到的exists
我的错误源于错误的代码const vis = new NeoVis(config)。它应该是const vis = new NeoVis(config.value)。我使用Vue3.js。如果没有.value,Neovis.js就无法初始化配置,并默认使用包含exists的Cypher子句。当我添加.value时,这个错误得到了解决,我的初始Cypher子句将被执行,而不包含exists

相关问题