EzDevInfo.com

neo4jphp

PHP wrapper of the Neo4j REST interface

Creating bi-directional relation between two nodes using the neo4jphp function "relateTo"

I create a relationship as the following in Neo4php

$src->relateTo($dst, 'FRIENDS')
    ->setProperty('duration', '5')
    ->save();

I want the relationship be undirected not directed. If I am not wrong we can do this in Cypher

create n-[:FRIENDS]-m

vs

create n-[:FRIENDS]->m

How about in Neo4jphp? Can we set "relateTo" to a bi-directional relationship?


Source: (StackOverflow)

How to reset neo4j database?

We can delete all nodes and relationships by following query.

MATCH (n) OPTIONAL MATCH (n)-[r]-() DELETE n,r

But newly created node get internal id as ({last node internal id} + 1) . It doesn't reset to zero.

How can we reset neo4j database such as newly created node will get id as 0?


Source: (StackOverflow)

Advertisements

Parametrizing relationship depth Neo4jphp

I am new to Neo4j. I have the following query in which I tried to parametrize the depth value for the relationship and it shows an error, If I remove parametrizing the depth value it works perfectly.

 $query="MATCH (a:user{id:{usd}})-[:likes*1..{depth}]->(b:product{id:{pid}})
         return a";
 $result = new Everyman\Neo4j\Cypher\Query($client, $query,
           array('usd' => 1234,'depth' => 3,'pid'=>3456));

Please help, Thanks in advance


Source: (StackOverflow)

How to push values to property array Cypher-Neo4j

I am new to Neo4j,I have two nodes user and files with a relationship :contains, the relationship has a property idwhich is an array, represented as

(:user)-[:contains{id:[12345]}]->(:files)

However I want to populate the property array id with values 1111 and 14567 sequentially using Cypher queries, I dont find any method to push values into the array.

after inserting 1111 to property id it will be

(:user)-[:contains{id:[12345,1111]}]->(:files)

after inserting 14567 to property id it will be

(:user)-[:contains{id:[12345,1111,14567]}]->(:files)

I dont know how to populate values to an property array sequentially

Please help, Thanks in advance


Source: (StackOverflow)

Neo4jPhp count Result retrival

In Neo4jPhp,
to get the result we use

foreach ($result as $row) {
    echo $row['x']->getProperty('Name') . "<br>";
}


But, When My Query is MATCH (n) RETURN count(n)
How to retrieve the result
I Tried

echo $row['x']->getProperty('0')

but, Its not working, HOW TO GET THE COUNT RESULT As it do not have field name?

On using echo $row['x']->getProperty('count(n)')<> Giving error

Fatal error: Call to a member function getProperty() on a non-object in D:\xampp\htdocs\abcd\index.php on line 17

Source: (StackOverflow)

working on Neo4j / graph database through php

I am working on a project for which I need work on graph database. So I have learnt basics of Neo4j (cypher language) .But I do not know how to access / query the database from php. Or suggest me any other way to work on graph database.

Help will be greatly appreciated.

composer.json

[
{
    "name": "monolog/monolog",
    "version": "1.13.1",
    "version_normalized": "1.13.1.0",
    "source": {
        "type": "git",
        "url": "https://github.com/Seldaek/monolog.git",
        "reference": "c31a2c4e8db5da8b46c74cf275d7f109c0f249ac"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/Seldaek/monolog/zipball/c31a2c4e8db5da8b46c74cf275d7f109c0f249ac",
        "reference": "c31a2c4e8db5da8b46c74cf275d7f109c0f249ac",
        "shasum": ""
    },
    "require": {
        "neoxygen/neoclient": "~2.1"
    },
    "provide": {
        "psr/log-implementation": "1.0.0"
    },
    "require-dev": {
        "aws/aws-sdk-php": "~2.4, >2.4.8",
        "doctrine/couchdb": "~1.0@dev",
        "graylog2/gelf-php": "~1.0",
        "phpunit/phpunit": "~4.0",
        "raven/raven": "~0.5",
        "ruflin/elastica": "0.90.*",
        "swiftmailer/swiftmailer": "~5.3",
        "videlalvaro/php-amqplib": "~2.4"
    },
    "suggest": {
        "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
        "doctrine/couchdb": "Allow sending log messages to a CouchDB server",
        "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
        "ext-mongo": "Allow sending log messages to a MongoDB server",
        "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
        "raven/raven": "Allow sending log messages to a Sentry server",
        "rollbar/rollbar": "Allow sending log messages to Rollbar",
        "ruflin/elastica": "Allow sending log messages to an Elastic Search server",
        "videlalvaro/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib"
    },
    "time": "2015-03-09 09:58:04",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "1.13.x-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Monolog\\": "src/Monolog"
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Jordi Boggiano",
            "email": "j.boggiano@seld.be",
            "homepage": "http://seld.be"
        }
    ],
    "description": "Sends your logs to files, sockets, inboxes, databases and various web services",
    "homepage": "http://github.com/Seldaek/monolog",
    "keywords": [
        "log",
        "logging",
        "psr-3"
    ]
},
{
    "name": "guzzlehttp/streams",
    "version": "2.1.0",
    "version_normalized": "2.1.0.0",
    "source": {
        "type": "git",
        "url": "https://github.com/guzzle/streams.git",
        "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/guzzle/streams/zipball/f91b721d73f0e561410903b3b3c90a5d0e40b534",
        "reference": "f91b721d73f0e561410903b3b3c90a5d0e40b534",
        "shasum": ""
    },
    "require": {
        "php": ">=5.4.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0"
    },
    "time": "2014-08-17 21:15:53",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.0-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "GuzzleHttp\\Stream\\": "src/"
        },
        "files": [
            "src/functions.php"
        ]
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Michael Dowling",
            "email": "mtdowling@gmail.com",
            "homepage": "https://github.com/mtdowling"
        }
    ],
    "description": "Provides a simple abstraction over streams of data (Guzzle 4+)",
    "homepage": "http://guzzlephp.org/",
    "keywords": [
        "Guzzle",
        "stream"
    ]
},
{
    "name": "guzzlehttp/guzzle",
    "version": "4.2.3",
    "version_normalized": "4.2.3.0",
    "source": {
        "type": "git",
        "url": "https://github.com/guzzle/guzzle.git",
        "reference": "66fd916e9f9130bc22c51450476823391cb2f67c"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/guzzle/guzzle/zipball/66fd916e9f9130bc22c51450476823391cb2f67c",
        "reference": "66fd916e9f9130bc22c51450476823391cb2f67c",
        "shasum": ""
    },
    "require": {
        "ext-json": "*",
        "guzzlehttp/streams": "~2.1",
        "php": ">=5.4.0"
    },
    "require-dev": {
        "ext-curl": "*",
        "phpunit/phpunit": "~4.0",
        "psr/log": "~1.0"
    },
    "suggest": {
        "ext-curl": "Guzzle will use specific adapters if cURL is present"
    },
    "time": "2014-10-05 19:29:14",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "4.2-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "GuzzleHttp\\": "src/"
        },
        "files": [
            "src/functions.php"
        ]
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Michael Dowling",
            "email": "mtdowling@gmail.com",
            "homepage": "https://github.com/mtdowling"
        }
    ],
    "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
    "homepage": "http://guzzlephp.org/",
    "keywords": [
        "client",
        "curl",
        "framework",
        "http",
        "http client",
        "rest",
        "web service"
    ]
},
{
    "name": "symfony/event-dispatcher",
    "version": "v2.7.0",
    "version_normalized": "2.7.0.0",
    "source": {
        "type": "git",
        "url": "https://github.com/symfony/EventDispatcher.git",
        "reference": "687039686d0e923429ba6e958d0baa920cd5d458"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/687039686d0e923429ba6e958d0baa920cd5d458",
        "reference": "687039686d0e923429ba6e958d0baa920cd5d458",
        "shasum": ""
    },
    "require": {
        "php": ">=5.3.9"
    },
    "require-dev": {
        "psr/log": "~1.0",
        "symfony/config": "~2.0,>=2.0.5",
        "symfony/dependency-injection": "~2.6",
        "symfony/expression-language": "~2.6",
        "symfony/phpunit-bridge": "~2.7",
        "symfony/stopwatch": "~2.3"
    },
    "suggest": {
        "symfony/dependency-injection": "",
        "symfony/http-kernel": ""
    },
    "time": "2015-05-02 15:21:08",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.7-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Symfony\\Component\\EventDispatcher\\": ""
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "description": "Symfony EventDispatcher Component",
    "homepage": "https://symfony.com"
},
{
    "name": "symfony/dependency-injection",
    "version": "v2.7.0",
    "version_normalized": "2.7.0.0",
    "source": {
        "type": "git",
        "url": "https://github.com/symfony/DependencyInjection.git",
        "reference": "137bf489c5151c7eb1e4b7dd34a123f9a74b966d"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/symfony/DependencyInjection/zipball/137bf489c5151c7eb1e4b7dd34a123f9a74b966d",
        "reference": "137bf489c5151c7eb1e4b7dd34a123f9a74b966d",
        "shasum": ""
    },
    "require": {
        "php": ">=5.3.9"
    },
    "conflict": {
        "symfony/expression-language": "<2.6"
    },
    "require-dev": {
        "symfony/config": "~2.2",
        "symfony/expression-language": "~2.6",
        "symfony/phpunit-bridge": "~2.7",
        "symfony/yaml": "~2.1"
    },
    "suggest": {
        "symfony/config": "",
        "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them",
        "symfony/yaml": ""
    },
    "time": "2015-05-29 14:44:44",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.7-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Symfony\\Component\\DependencyInjection\\": ""
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "description": "Symfony DependencyInjection Component",
    "homepage": "https://symfony.com"
},
{
    "name": "symfony/filesystem",
    "version": "v2.7.0",
    "version_normalized": "2.7.0.0",
    "source": {
        "type": "git",
        "url": "https://github.com/symfony/Filesystem.git",
        "reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/symfony/Filesystem/zipball/ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
        "reference": "ae4551fd6d4d4f51f2e7390fbc902fbd67f3b7ba",
        "shasum": ""
    },
    "require": {
        "php": ">=5.3.9"
    },
    "require-dev": {
        "symfony/phpunit-bridge": "~2.7"
    },
    "time": "2015-05-15 13:33:16",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.7-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Symfony\\Component\\Filesystem\\": ""
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "description": "Symfony Filesystem Component",
    "homepage": "https://symfony.com"
},
{
    "name": "symfony/config",
    "version": "v2.7.0",
    "version_normalized": "2.7.0.0",
    "source": {
        "type": "git",
        "url": "https://github.com/symfony/Config.git",
        "reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/symfony/Config/zipball/537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
        "reference": "537e9912063e66aa70cbcddd7d6e6e8db61d98e4",
        "shasum": ""
    },
    "require": {
        "php": ">=5.3.9",
        "symfony/filesystem": "~2.3"
    },
    "require-dev": {
        "symfony/phpunit-bridge": "~2.7"
    },
    "time": "2015-05-15 13:33:16",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.7-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Symfony\\Component\\Config\\": ""
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "description": "Symfony Config Component",
    "homepage": "https://symfony.com"
},
{
    "name": "symfony/yaml",
    "version": "v2.7.0",
    "version_normalized": "2.7.0.0",
    "source": {
        "type": "git",
        "url": "https://github.com/symfony/Yaml.git",
        "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/symfony/Yaml/zipball/4a29a5248aed4fb45f626a7bbbd330291492f5c3",
        "reference": "4a29a5248aed4fb45f626a7bbbd330291492f5c3",
        "shasum": ""
    },
    "require": {
        "php": ">=5.3.9"
    },
    "require-dev": {
        "symfony/phpunit-bridge": "~2.7"
    },
    "time": "2015-05-02 15:21:08",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.7-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Symfony\\Component\\Yaml\\": ""
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "description": "Symfony Yaml Component",
    "homepage": "https://symfony.com"
},
{
    "name": "symfony/console",
    "version": "v2.7.0",
    "version_normalized": "2.7.0.0",
    "source": {
        "type": "git",
        "url": "https://github.com/symfony/Console.git",
        "reference": "7f0bec04961c61c961df0cb8c2ae88dbfd83f399"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/symfony/Console/zipball/7f0bec04961c61c961df0cb8c2ae88dbfd83f399",
        "reference": "7f0bec04961c61c961df0cb8c2ae88dbfd83f399",
        "shasum": ""
    },
    "require": {
        "php": ">=5.3.9"
    },
    "require-dev": {
        "psr/log": "~1.0",
        "symfony/event-dispatcher": "~2.1",
        "symfony/phpunit-bridge": "~2.7",
        "symfony/process": "~2.1"
    },
    "suggest": {
        "psr/log": "For using the console logger",
        "symfony/event-dispatcher": "",
        "symfony/process": ""
    },
    "time": "2015-05-29 16:22:24",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.7-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Symfony\\Component\\Console\\": ""
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Fabien Potencier",
            "email": "fabien@symfony.com"
        },
        {
            "name": "Symfony Community",
            "homepage": "https://symfony.com/contributors"
        }
    ],
    "description": "Symfony Console Component",
    "homepage": "https://symfony.com"
},
{
    "name": "neoxygen/neoclient",
    "version": "2.2.3",
    "version_normalized": "2.2.3.0",
    "source": {
        "type": "git",
        "url": "https://github.com/neoxygen/neo4j-neoclient.git",
        "reference": "f7fc5f76c1273bfe7b7346cac29272dac3142ea2"
    },
    "dist": {
        "type": "zip",
        "url": "https://api.github.com/repos/neoxygen/neo4j-neoclient/zipball/f7fc5f76c1273bfe7b7346cac29272dac3142ea2",
        "reference": "f7fc5f76c1273bfe7b7346cac29272dac3142ea2",
        "shasum": ""
    },
    "require": {
        "guzzlehttp/guzzle": "4.*",
        "monolog/monolog": "~1.1",
        "php": ">= 5.4",
        "symfony/config": "~2.5",
        "symfony/console": "~2.5",
        "symfony/dependency-injection": "~2.5",
        "symfony/event-dispatcher": "~2.5",
        "symfony/yaml": "~2.5"
    },
    "require-dev": {
        "behat/behat": "~3.0",
        "bossa/phpspec2-expect": "*",
        "phpspec/phpspec": "~2.0",
        "phpunit/phpunit": "4.*"
    },
    "time": "2015-06-05 18:12:15",
    "type": "library",
    "extra": {
        "branch-alias": {
            "dev-master": "2.1-dev"
        }
    },
    "installation-source": "dist",
    "autoload": {
        "psr-4": {
            "Neoxygen\\NeoClient\\": "src/"
        }
    },
    "notification-url": "https://packagist.org/downloads/",
    "license": [
        "MIT"
    ],
    "authors": [
        {
            "name": "Christophe Willemsen",
            "email": "chris@neoxygen.io"
        }
    ],
    "description": "NeoClient is the most advanced Http Client for Neo4j",
    "homepage": "http://neoxygen.io",
    "keywords": [
        "client",
        "cluster",
        "graph",
        "high-availibility",
        "neo4j"
    ]
}

]


Source: (StackOverflow)

neo4j: authentication - only allow reading cypher queries

I'm using neo4j 1.9.4 and I would like to display some information about the graph on a (public) website using neo4jphp. In order to fetch some data I use cypher queries within neo4jphp. Those queries obviously only read data from the graph.

I have to make sure that visitors of the website are unable to modify any data in the graph. Therefore, I set up the authentication-extension plugin and created two users (one with read-only 'RO' and one with read-write 'RW' access rights) as documented there. However, the cypher queries within neo4jphp only work for the user with RW rights but not for the one with RO rights.

I know that http://docs.neo4j.org/chunked/stable/security-server.html#_security_in_depth pretty much explains how to secure neo4j, but I absolutely can't figure out how to do that. Especially the section "arbitrary_code_execution" seems to be interesting, but I don't know how to make use of it.

How can I achieve that reading cypher queries can be executed from the web server? BTW: The web server (to display some results) and neo4j are running on a different machine.

I would appreciate any help, thank you!

EDIT: My scenario is actually not that complicated, so I'm sure there must be a solution for that: From localhost any access (read write) is granted, whereas access from a remote web server is restricted to reading from the graph. How can I achieve that? If that is not possible: How could I restrict access from remote web server to some predefined (cypher) queries, where only some parameters can be supplied by the user?


Source: (StackOverflow)

what does transaction mean in reference with neo4j database

I got a bit confuse with term transaction. Suppose in transaction A we have two commands C1 and C2 and same in transaction B. Now both transaction come at same time then Are these observations correct?

  1. All commands of transaction A C1 and C2 will be done first (assuming A enter first) , then only commands of transaction B will be executed.

  2. Any command of transaction A or B can be executed but with assurance that If any of the command fails of any of the transaction then that transaction will be rollback.

  3. If second case is true then in transaction by default, it do not lock any resource until its completion

  4. If first case is true then by default transaction hold lock on resources until their completion.

thanks

Amit Aggarwal


Source: (StackOverflow)

Neo4j write performance improvement

I have scenarios like below:

CREATE (p:Person{guid:1})
CREATE (b1:Book{guid:1})
CREATE (b2:Book{guid:2})
CREATE (b3:Book{guid:3})

MATCH (p:Person{guid:1}),(b1:Book{guid:1}) CREATE (p)-[:READ]->(b1)
MATCH (p:Person{guid:1}),(b2:Book{guid:2}) CREATE (p)-[:READ]->(b2)
MATCH (p:Person{guid:1}),(b3:Book{guid:3}) CREATE (p)-[:READ]->(b3)

Currently, above cypher queries are run sequentially. I need to improve the performance my of write operations.

I think creation of p,b1,b2,b3 can happen in parallel. Once this is done, connection between p and b1,b2,and b3 can happen in parallel. Also, I think above queries can go in a single batch instead of separate write operations.

I am using neo4jphp and node-neo4j.

I think we have Transactional Cypher HTTP endpoint and Batch operations. Whether these improve the write performance? Which of this is better for above case?

Looks like neo4jphp supports batch and cypher transactions. But not sure whether it is possible to achieve batch/cypher transactions in node-neo4j.


Source: (StackOverflow)

Cypher: Passing multiple parameters in WHRE IN

How to pass parameters for WHERE condition?

That it is, this works fine:

match (b:Book) where b.guid={guid} return b;

But, how to pass multiple guids as parameters for this query:

match (b:Book) where b.guid in [guid1,guid2,gid3] return b;

I am using neo4jphp client, my code is like this:

$client = new Everyman\Neo4j\Client( "neo4j server address", "7474" );
$result = new Everyman\Neo4j\Cypher\Query( $client, "match (b:Book) where b.guid={guid} return b", array('guid'=>$guid1) );
$res = $result->getResultSet();

Source: (StackOverflow)

Several parallel batches in Neo4jphp

Is it possible to create several batches at one time?

For example I have a code that has a running batch (batch 1). And inside this batch I have a method called which has another batch inside it (batch 2). The code is not working.

When I remove the upper batch (batch 1) I have a created node. Maybe there is only 1 batch possible at one time?

The example code is below:

$batch = $client->startBatch();

$widget = NULL;

try {
    $widgetLabel = $client->makeLabel('Widget');

    $widget = $client->makeNode();
    $widget
        ->setProperty('base_filename', md5(uniqid('', TRUE)))
        ->setProperty('datetime_added', time())
        ->setProperty('current_version', 0)
        ->setProperty('shared', 0)
        ->setProperty('active', 1)
    ->save();

    // add widget history
    $history = Model_History::create($widget, $properties);

    if ($history == NULL) {
        throw new Exception('Could not create widget history!');
    }

    $widget->setProperty('current_version', $history->getID());
    $widget->save();

    $client->commitBatch($batch);
} catch (Exception $e) {
    $client->endBatch();
}

The batch 2 is inside the Model_History::create() method. I don't get a valid $widget - Neo4jphp node from this code.


Source: (StackOverflow)

neo4j Index cretion in a Mysql migration to neo4j

Regarding the creation of index for the nodes that we create I have a question..

If i make a migration from MySql to neo4j graph db do I have to create an index for every record or it's ok to create at the end ?

PS: Sorry for the dumb question I am new to it and I am trying to learn. here is the code: ` $query = 'SELECT * FROM product'; $result = mysql_query ($query);

while ( $row = mysql_fetch_array ($result) ) {
    $product = $this->client->makeNode ();
    $product->setProperty ('product_id',(int)$row[ 'product_id' ])
        ->setProperty ('sku', $row[ 'sku' ])
        ->save ();
    $productIndex =  new NodeIndex($this->client,'products');
    $productIndex->save();
    $productLabel = $this->client->makeLabel ('product');
    $product->addLabels (array ( $productLabel ));

    echo "Done creating " . $row[ 'product_id' ] . " node<br/>";

}`

also I am wondering how do I see i the index was created (in browser) or I cant see it only feel it? Thank you !


Source: (StackOverflow)

neo4j cypher - Unable to execute query [400], 'StackOverflowError' exception

I am getting this exception when I try to run a long query:

Unable to execute query [400]:\nHeaders: Array\n(\n [Content-Type] => application/json; charset=UTF-8; stream=true\n [Access-Control-Allow-Origin] => *\n [Transfer-Encoding] => chunked\n [Server] => Jetty(9.0.5.v20130815)\n)\nBody: Array\n(\n [exception] => StackOverflowError\n [fullname] => java.lang.StackOverflowError\n [stacktrace] => Array\n (\n [0] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [1] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [2] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [3] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [4] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [5] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [6] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [7] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [8] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [9] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [10] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [11] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [12] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [13] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [14] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [15] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [16] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [17] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [18] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [19] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [20] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [21] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [22] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [23] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [24] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [25] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [26] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [27] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [28] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [29] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [30] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [31] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [32] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [33] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [34] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [35] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [36] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [37] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [38] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [39] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [40] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [41] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [42] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [43] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [44] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [45] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [46] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [47] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [48] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [49] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [50] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [51] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [52] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [53] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [54] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [55] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [56] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [57] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [58] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [59] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [60] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [61] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [62] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [63] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [64] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [65] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [66] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [67] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [68] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [69] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [70] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [71] => scala.collection.AbstractIterator.toList(Iterator.scala:1157)\n [72] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter.apply(Rewritable.scala:137)\n [73] => org.neo4j.cypher.internal.compiler.v2_1.bottomUp$BottomUpRewriter$$anonfun$1.apply(Rewritable.scala:137)\n [74] => scala.collection.Iterator$$anon$11.next(Iterator.scala:328)\n [75] => scala.collection.Iterator$class.foreach(Iterator.scala:727)\n [76] => scala.collection.AbstractIterator.foreach(Iterator.scala:1157)\n [77] => scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)\n [78] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)\n [79] => scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)\n [80] => scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)\n [81] => scala.collection.AbstractIterator.to(Iterator.scala:1157)\n [82] => scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)\n [83] => scal

Query:

start k=node:node_auto_index("title:abc*") where k.id in [123,456,...] return distinct k.prop;

Above where has list of around 3000 ids. I am using neo4j-community-2.1.2 and neo4jphp. Is there any work around to this?


Source: (StackOverflow)

Neo4jphp batch problems

  1. When I try to execute $node->addLabels(array($label)) and batch is not committed yet I get an exception. So we cannot add label to node during batch at all? Or any workaround is possible?

  2. When I try to get ID of the new created node $node->getID() during batch I get null. ID is available only after the batch is committed. Any way to get ID before the commit?


Source: (StackOverflow)

Add properties to relationships in a neo4j database using neo4j-OGM in PHP

while we are able to create new nodes etc., we are still struggling to find out how properties can be added to existing relationships. For instance we are declaring the following in an Entity format:

   /**
     * @OGM\ManyToMany(relation="GOES_TO_MARKET")
     */
    protected $shoppers;

How do we make it so that we can add additional properties to GOES_TO_MARKET using doctrine format?

Thanks


Source: (StackOverflow)