I am just started with the Procedures in Neo4j. And, wanted to look into the Built In Procedures. I ma using the community edition software. And, I have tried to list the labels in the database.
Query:
CALL db.labels()
Error:
Invalid input 'A': expected 'r/R' (line 1, column 2 (offset: 1))
"CALL db.labels()"
^
Do I need to run any query to make neo4j aware of this CALL command. I am simply running this in the Web Interface only.
Neo4j 3.X+ versions support Procedures. (2.X or earlier version caused the Error). We can directly run the CALL db.labels() in Web Interface which in turn returns the list of labels in the Data base.
And User defined procedures cannot be created directly using cypher. Currently we can create a procedure using JAVA Api only.
Related
I am trying to connect to my organisation's SQL database using Power Query to create some reports. I need to delete/edit some tables and join multiple tables to come up with the desired report output...
I don't want the change or edit I will do on the excel-power query to reflect on the live database but just in excel .
The short answer is no, any button you press in the Power Query Editor interface does not modify the source database. I must admit that I have not found any page in the Microsoft Docs on Power Query that states this clearly. The page What is Power Query? states that:
Power Query is a data transformation and data preparation engine. Power Query comes with a graphical interface for getting data from sources and a Power Query Editor for applying transformations.
Other pages contain similarly general and vague descriptions but let me reassure you that any data transformation you carry out by using the Power Query Editor interface will not modify your SQL database. All you see in Power Query is a view of the source database.
Seeing as you are connecting to a SQL database, it is likely that query folding is activated. This means that when you remove a column (or row), this will update the SQL query used to extract the data from the database. That query is written as a single SELECT statement that can contain multiple clauses like GROUP BY and WHERE. Transformations that add data (e.g. Add Custom Column, Fill Down) are not included in the query, they are carried out only within the Power Query engine. You can read more about this in the docs.
How to edit a database with Power Query when native SQL queries are supported
That being said, you can actually edit a database from within Power Query if the database supports the use of native SQL queries, if you have write permission for the database, and if you edit and run one of the two M functions that let you write native SQL queries. Here is an example using the Sql.Database function:
Sql.Database("servername", "dbname", [Query = "DROP TABLE tablename"])
And here is an example using the Value.NativeQuery function:
Source = Sql.Databases("servername"){[Name="dbname"]}[Data],
#"Native Query" = Value.NativeQuery(Source, "DROP TABLE tablename")
Unless you have changed the default Query Options, these functions should raise a warning message requiring you to permit running the query:
This prevents you from modifying the database without confirmation, so any database modification cannot happen just by accident.
I verified this using Excel Microsoft 365 (Version 2108) on Windows 10 64-bit connected to a local SQL Server 2019 (15.x) database.
I'm new to neo4j and graph databases in general.
Given a complex Cypher query, that I don't want to store inside the application (or several applications), but keep centralized, what options are left to me?
In a SQL database I would use a stored function. Are UDF function the way to go in neo4j?
From the docs it seems to me that they're more a way to extend the database functionality by being able to access the graph internals, but I've just started studying them.
Take a look at the custom functions and procedures available in the apoc library.
https://neo4j.com/docs/labs/apoc/current/cypher-execution/cypher-based-procedures-functions/
CALL apoc.custom.asProcedure('answer','RETURN 42 as answer')
CALL custom.answer() YIELD row RETURN row.answer
I've compiled the latest Neo4j Spatial (neo4j-spatial-0.16-neo4j-3.0.0-server-plugin.jar) from source and dropped it into my Neo4j 3.0.0 plugins folder.
The extension is listed in the browser, and I can do POST calls for spatial functionality.
However, I believe I should also be able to use the nifty new CALL feature in Neo4j 3.0.0 to make Cypher calls, like this:
CALL spatial.addPointLayer('cities');
As alluded to by Stefan's update here:
How do I create a spacial index in neo4j using only cypher?
And shown here:
http://jexp.github.io/graphgist/idx?dropbox-14493611%2Fcypher_spatial.adoc
However, I get a "There is no procedure with the name spatial.addPointLayer registered for this database instance." error, and can see the same calls failing in the jexp example as well... I'm not sure if I'm just too early to the party or missing something?
The plugin needs to be in the database-specific Plugin folder and not in the "Neo4j CE 3.0.x/Plugins" folder.
In Neo4j 3.0, for basic operations you don't need the spatial plugin.
There is default support for point and distance. This support assumes you will set lat/lon property keys as latitude and longitude.
You can the use them for calculating distance between two nodes, for example :
MATCH (a:City {name:'London'}), (b:City {name:'Barcelona'})
RETURN distance(point(a), point(b))/1000 as dist
You can find a detailed example in this graphgist :
http://gist.asciidoctor.org/?dropbox-14493611%2Fcypher_spatial.adoc#_spatial_procedures
Secondly, in Neo4j 3.0 appears stored procedures, an official set of procedures is supported by neo4j here :
https://github.com/neo4j-contrib/neo4j-apoc-procedures
Which provides some more spatial features.
I am new to neo4j. I have created graph database in neo4j i.e "my.graphdb" which also include schema indexes. Now I want to use this database into my java program. For that I used batch insertion. Also I am creating schema indexes in my java program. But when I run the program it gives me following exception.
Exception :
java.lang.UnsupportedOperationException: Schema modification is currently not available
through the BatchDatabase API.
In short, I want to use my existing graph database (my.graphdb) into new java program. Moreover, I want to use my existing data and indexes present in my.graphdb to insert new nodes and relationships.
Please let me know what should I do ?
The BatchGraphDatabase should not be used.
Use the BatchInserter or the transactional EmbeddedGraphDatabase.
The Batchinserter also supports the creation of schema indexes which are populated at shutdown (test with a small dataset first, it can take a while, will be faster in 2.0.1).
I'm using neo4j 1.7 through the REST interface, and I punched in the following query:
{"script": "g.v(1).aggregate(x); g.V.except(x)", "params": {"x":[]}}
which should return the list, missing Node 1, but instead this returns the entire list of Nodes. I've looked over the neo4j documentation and see examples of using variables, but this query does not seem to behave as exepected.
Has anyone else run into this problem or is this something can't/shouldn't be done through the gremlin REST interface?
When you're not in the Gremlin REPL, you need to manually iterate expressions when it's not the last expression returned (the Gremlin Plugin automatically iterates the last expression):
g.v(1).aggregate(x).iterate(); g.V.except(x)
But you can simplify it down to one statement like this:
g.V.except([g.v(1)])