如何使用Sigmajs和Neo4j进行输入搜索来检索节点?

时间:2018-02-13 15:54:15

标签: javascript neo4j sigma.js

我正在尝试使用inputsearch字段检索节点但它不起作用。我认为密码查询中存在错误。有人可以帮助我吗?

var inputsearch= document.getElementById('inputsearch').value;
var buttonSearch=document.getElementById('buttonsearch');    
buttonSearch.addEventListener('click', drawGraph(inputsearch));   




function drawGraph(inputsearch){


    sigma.neo4j.cypher(
      {
        url: 'http://localhost:7474', user: 'neo4j', password: 'neo4j' },

      'match (n)-[r]->(m) where n.data.node.label =~ ".*(?i)'+inputsearch+'.*" return r,m,n;',s
      ,function(s) {
        console.log('Number of nodes :'+ s.graph.nodes().length);
        console.log('Number of edges :'+ s.graph.edges().length);
        for(var i =0;i < s.graph.nodes().length; i++){
          node = s.graph.nodes()[i];
            s.settings('touchEnabled', true);
            s.settings('mouseEnabled', true);


}})};        

1 个答案:

答案 0 :(得分:1)

这不是一个西格玛问题,而是一个Neo4j问题。

如果你想这样做,你应该:

  • 在每个节点上添加标签Node
  • 在每个要连接的节点上添加属性_search 小写所有要编制索引的字段
  • 在节点_search的属性Node上创建索引:CREATE INDEX ON :Node(_search)

随着您的查询变为:

MATCH (n:Node)-[r]->(m) WHERE n._search CONTAINS $inputsearch RETURN n LIMIT 1

我已更新我的jsfiddle:https://jsfiddle.net/sim51/qkc0g58o/69/