通过密码查询获取属性

Fetching properties through cypher query

我正在尝试使用嵌入在 neovis javascript 中的密码查询来获取以下 Json 的属性。问题是节点的实体名称没有出现。

JSON

{
  "start": {
"identity": 0,
"labels": [
      "Entity"
    ],
"properties": {
"text": "Christian Drosten",
"id": "Q1079331"
    }
  },
  "end": {
"identity": 3,
"labels": [
      "Entity"
    ],
"properties": {
"id": "Q95",
"text": "Google"
    }
  },
  "segments": [
    {
      "start": {
"identity": 0,
"labels": [
          "Entity"
        ],
"properties": {
"text": "Christian Drosten",
"id": "Q1079331"
        }
      },
      "relationship": {
"identity": 1,
"start": 0,
"end": 3,
"type": "EMPLOYER",
"properties": {

        }
      },
      "end": {
"identity": 3,
"labels": [
          "Entity"
        ],
"properties": {
"id": "Q95",
"text": "Google"
        }
      }
    }
  ],
  "length": 1.0
}

HTML 使用 Neovis 和密码查询的代码

<!doctype html>
<html>
<head>
    <title>Neovis.js Simple Example</title>
    <style type="text/css">
        html, body {
            font: 16pt arial;
        }

        #viz {
            width: 900px;
            height: 700px;
            border: 1px solid lightgray;
            font: 22pt arial;
        }

    </style>

    <!-- FIXME: load from dist -->
    <script type="text/javascript" src="https://cdn.neo4jlabs.com/neovis.js/master/neovis.js"></script>


    <script
            src="https://code.jquery.com/jquery-3.2.1.min.js"
            integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
            crossorigin="anonymous"></script>

    <script type="text/javascript">
        // define config car
        // instantiate nodevis object
        // draw

        var viz;

        function draw() {
            var config = {
                container_id: "viz",
                server_url: "bolt://localhost:7687",
                server_user: "neo4j",
                server_password: "password",

                 relationships: {
                    "EMPLOYER": {
                        "caption": true
                    }
                },
                initial_cypher: "MATCH p=(n)-[r:EMPLOYER]->(m) RETURN p",
                arrows: false
            };

            viz = new NeoVis.default(config);
            viz.render();
            console.log(viz);

        }
    </script>
</head>
<body onload="draw()">
<div id="viz"></div>


Cypher query: <textarea rows="4" cols=50 id="cypher"></textarea><br>
<input type="submit" value="Submit" id="reload">


</body>

<script>
    $("#reload").click(function() {

        var cypher = $("#cypher").val();

        if (cypher.length > 3) {
            viz.renderWithCypher(cypher);
        } else {
            console.log("reload");
            viz.reload();

        }

    });

</script>
</html>

当前输出

预期输出

我希望看到标记到节点的实际名称而不是实体,即 Christian Drosten 和 Google

如果我理解你的问题,你需要在你的 neoviz 配置中添加以下内容:

labels: {
    "Entity": {
         "caption": "name",
    }
}

请参阅文档 here