0
votes

I need to export the result of a query of neo4j database to JSON or CSV, including relations and nodes, my query is this:

MATCH (s:Socio)-[:ES_SOCIO_DE]->(p1:Empresas)-[:OFERTA_A]->(lic:Licitaciones)<-[:OFERTA_A]-(p2:Empresas)<-[:ES_SOCIO_DE]-(s:Socio) WHERE ID(p1) <> ID(p2) RETURN * limit 100

but when I tried to export it to GraphML for example, it only exports the nodes

Image

1
I solve it, actually it was really simple, I just add this: MATCH (s:Socio)-[r1:ES_SOCIO_DE]->(p1:Empresas)-[r3:OFERTA_A]->(lic:Licitaciones)<-[r4:OFERTA_A]-(p2:Empresas)<-[r2:ES_SOCIO_DE]-(s:Socio) WHERE ID(p1) <> ID(p2) RETURN * limit 10José Mora

1 Answers

0
votes

Do you have access to the Neo4j browser interface for your installation? Usually, the URL will be something like:

http://[IP_ADDRESS_OF_YOUR_NEO4J_SERVER]:7474/browser/

In the browser interface, you can run your query in the query box, then click either the 'Text' or 'Table' panel on the left side of the returned query results box and you will see that you now have the option to 'Export CSV' in the top right portion of the returned query results box.

You can then either open the CSV directly or save it - and it will contain the nodes and the relationship properties.

If you want to return the type of the relationship (rather than just the properties) - which I have a hunch may be the case - return the relationship variable encapsulated in the built-in type() function. For example, using Neo4j's sample Movie database, I run the following query:

optional match (z:Person)-[x:ACTED_IN]->(v:Movie)
where z.name = "Tom Cruise"
return z,type(x),v

With the above query, rather than returning me the properties of his [:ACTED_IN] relationship, it will simply return "ACTED_IN"

Edit: Judging from your included image, which I admittedly did not notice initially, it looks like the relationships being returned are zero. Are you sure that the relationship that you are specifying actually exists?