Document directory
- 1.1Neo4j Server Installation
- 1.2Neo4j Server configuration parameters
- 2.1 install the Spatail plug-in of Neo4j Server
- 2.2 Neo4j Server spatial operations
- 1.1Neo4j Server Installation
- 1.2Neo4j Server configuration parameters
- 2.1 install the Spatail plug-in of Neo4j Server
- 2.2 Neo4j Server spatial operations
Graph database practice series (iii) -- REST integration of Neo4j Spatial-Forest Farm-blog Park
Graph database practice series (iii) -- REST integration of Neo4j Spatial
Last Review: This article mainly describes the Neo4j Spatial project and space data (vector) storage. This article describes how to integrate Neo4j Spatial with Neo4j Server and GeoServer.
Noted:The integration method with Geoserver is feasible, but geoserverUnable to displayPublishLayer. (System environment: Ubuntu 12.04, Spatial 0.9, Neo4j 1.8M6, Geoserver 2.1.1)
1. install and configure Neo4j Server 1.1install Neo4j Server
Neo4j can be installed as a database server and can run in the operating system in two forms: application or system service. It has built-in jetty and REST interfaces to operate databases using browsers [].
- Download your version on the neo4j official website http://neo4j.org/download( select your operating system)
- Decompress the package to a specific location. The decompressed path is expressed$ NEO4J_HOME(For example,/home/dev/neo4j /)
- Start the script in$ NEO4J_HOME/binUnder Linux/MacOS, to run $ NEO4J_HOME/bin/neo4j start in Window, double-click the % NEO4J_HOME % \ bin \ Neo4j. bat file.
We can also go to the bin folder ($ NEO4J_HOME/bin) of Neo4j installed in the source code as described in section 1 to start the command,
cd $NEO4J_HOME/bin/$NEO4J_HOME/bin/neo4j start
We only need to access http: // localhost: 7474/webadmin/. The web management interface of Neo4j appears, as shown in 1:
Figure 1 Neo4j Server Management page
On the Web management interface, we can view database nodes, attributes, and link information. You can also perform CRUD on Graph databases through Http, Shell, and Germlin. If you need to run Neo4j Server as a system service, refer to references [17].
1.2Neo4j Server configuration parameters
If you need to optimize the performance of the backend database of the Server, you can use the Server configuration file to understand the specific parameters of the graph database. These important parameters are stored in$ NEO4J_HOME/conf/neo4j-server.propertiesFile, including the path of the server database on disk:
org.neo4j.server.database.location=data/graph.db
Http server interface:
org.neo4j.server.database.location=data/graph.db
Set the relative path of the database that the REST data interface can manipulate
org.neo4j.server.webadmin.data.uri=/db/data/
. For performance parameters and log parameters of Neo4j, see$ NEO4J_HOME/conf/neo4j. properties,$ NEO4J_HOME/Conf/logging. propertiesTwo files.
2. Neo4j Server and Spatial are integrated. 2.1 install the Spatail plug-in of Neo4j Server
We have installed neo4j spatial by using the source code. A file named neo4j-spatial-0.9-snapshot-server-plugin.zip is available in the/targetdirectory. If not, run the following command to obtain the file:
git clone https://github.com/neo4j/spatial.gitcd ./spatialmvn clean package -DskipTests
Decompress the file and copy all the jar packagesNeo4jOfLibFolder, and then restart the neo4j server.
2.2 Neo4j Server spatial operations
The curl [20] tool can be used to read and write spatial data to Neo4j in the command line, including query, layer creation, and point creation. These operations are performed on Graph databases in JSON format using the http protocol.
curl http://localhost:7474/db/data/
The overall information of the database is returned, as shown in Figure 2:
Figure 2 query graph Databases
The returned JSON data contains the "SpatialPlugin" object. Its attributes include addEditableLayer, getLayer, and addNodeToLayer. We use the curl command to create simple vertex layers such as 'test.
curl -d "layer=test" http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer
3:
Figure 3 add a vertex Layer
You can see the attributes of the data formation, including the layer class, layer name, geometric encoding type, and creation time. Then add three vertices in Well-Konw text format
# Creating three points from Well-known text formatcurl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer -H "Content-Type: application/json" -d '{"geometry":"POINT(10 10)", "layer":"test"}'curl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer -H "Content-Type: application/json" -d '{"geometry":"POINT(10 11)", "layer":"test"}'curl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer -H "Content-Type: application/json" -d '{"geometry":"POINT(9 10)", "layer":"test"}'
Then execute a Range Query
curl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findGeometriesInBBox -H "Content-Type: application/json" -d '{"minx":9.0,"maxx":11.0,"miny":9.0,"maxy":12.0,"layer":"test"}'
Two vertices in the boundary are returned, as shown in figure 4:
Figure 4 Range Query
3. Integration with GeoServer
GeoServer is a java-based Open Source map server that supports various data sources, including shapefile and postgis. Neo4j spatial can be integrated with GeoServer in the form of plug-ins. The integration method is as follows:
- Uncompress neo4j-spatial-0.9-snapshot-server-plugin.zip and copy the jar packages except gt-* _ 8.0 to the geoserver/WEB-INF/lib folder.
- Copy all the jar files in neo4j/lib to the geoserver/WEB-INF/lib folder.
- Restart geoserver
By accessing the GeoServer address http: // localhost: 8080/geoserver/web/, we can see that, as shown in-5, neo4j can serve as the back end of geoserver and provide the map service.
Figure 5 integrate neo4j with geoserver
However, geoserver cannot display the layer in the published database. (System environment: Ubuntu 12.04, Spatial 0.9, Neo4j 1.8M6, Geoserver 2.1.1)
It is said to be a geoserver bug and will be fixed soon. Https://github.com/neo4j/spatial/issues/57
The next lecture will focus on a graph database Titan Based on HBase.
References
[17] Server Installation http://docs.neo4j.org/chunked/stable/server-installation.html
[18] Jetty http://jetty.codehaus.org/jetty/
[19] Server Configuration http://docs.neo4j.org/chunked/stable/server-configuration.html
[20] cURL http://curl.haxx.se/
[21] Well-known text http://en.wikipedia.org/wiki/Well-known_text
Last Review: This article mainly describes the Neo4j Spatial project and space data (vector) storage. This article describes how to integrate Neo4j Spatial with Neo4j Server and GeoServer.
Noted:The integration method with Geoserver is feasible, but geoserverUnable to displayPublishLayer. (System environment: Ubuntu 12.04, Spatial 0.9, Neo4j 1.8M6, Geoserver 2.1.1)
1. install and configure Neo4j Server 1.1install Neo4j Server
Neo4j can be installed as a database server and can run in the operating system in two forms: application or system service. It has built-in jetty and REST interfaces to operate databases using browsers [].
- Download your version on the neo4j official website http://neo4j.org/download( select your operating system)
- Decompress the package to a specific location. The decompressed path is expressed$ NEO4J_HOME(For example,/home/dev/neo4j /)
- Start the script in$ NEO4J_HOME/binUnder Linux/MacOS, to run $ NEO4J_HOME/bin/neo4j start in Window, double-click the % NEO4J_HOME % \ bin \ Neo4j. bat file.
We can also go to the bin folder ($ NEO4J_HOME/bin) of Neo4j installed in the source code as described in section 1 to start the command,
cd $NEO4J_HOME/bin/$NEO4J_HOME/bin/neo4j start
We only need to access http: // localhost: 7474/webadmin/. The web management interface of Neo4j appears, as shown in 1:
Figure 1 Neo4j Server Management page
On the Web management interface, we can view database nodes, attributes, and link information. You can also perform CRUD on Graph databases through Http, Shell, and Germlin. If you need to run Neo4j Server as a system service, refer to references [17].
1.2Neo4j Server configuration parameters
If you need to optimize the performance of the backend database of the Server, you can use the Server configuration file to understand the specific parameters of the graph database. These important parameters are stored in$ NEO4J_HOME/conf/neo4j-server.propertiesFile, including the path of the server database on disk:
org.neo4j.server.database.location=data/graph.db
Http server interface:
org.neo4j.server.database.location=data/graph.db
Set the relative path of the database that the REST data interface can manipulate
org.neo4j.server.webadmin.data.uri=/db/data/
. For performance parameters and log parameters of Neo4j, see$ NEO4J_HOME/conf/neo4j. properties,$ NEO4J_HOME/Conf/logging. propertiesTwo files.
2. Neo4j Server and Spatial are integrated. 2.1 install the Spatail plug-in of Neo4j Server
We have installed neo4j spatial by using the source code. A file named neo4j-spatial-0.9-snapshot-server-plugin.zip is available in the/targetdirectory. If not, run the following command to obtain the file:
git clone https://github.com/neo4j/spatial.gitcd ./spatialmvn clean package -DskipTests
Decompress the file and copy all the jar packagesNeo4jOfLibFolder, and then restart the neo4j server.
2.2 Neo4j Server spatial operations
The curl [20] tool can be used to read and write spatial data to Neo4j in the command line, including query, layer creation, and point creation. These operations are performed on Graph databases in JSON format using the http protocol.
curl http://localhost:7474/db/data/
The overall information of the database is returned, as shown in Figure 2:
Figure 2 query graph Databases
The returned JSON data contains the "SpatialPlugin" object. Its attributes include addEditableLayer, getLayer, and addNodeToLayer. We use the curl command to create simple vertex layers such as 'test.
curl -d "layer=test" http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addSimplePointLayer
3:
Figure 3 add a vertex Layer
You can see the attributes of the data formation, including the layer class, layer name, geometric encoding type, and creation time. Then add three vertices in Well-Konw text format
# Creating three points from Well-known text formatcurl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer -H "Content-Type: application/json" -d '{"geometry":"POINT(10 10)", "layer":"test"}'curl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer -H "Content-Type: application/json" -d '{"geometry":"POINT(10 11)", "layer":"test"}'curl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/addGeometryWKTToLayer -H "Content-Type: application/json" -d '{"geometry":"POINT(9 10)", "layer":"test"}'
Then execute a Range Query
curl -v http://localhost:7474/db/data/ext/SpatialPlugin/graphdb/findGeometriesInBBox -H "Content-Type: application/json" -d '{"minx":9.0,"maxx":11.0,"miny":9.0,"maxy":12.0,"layer":"test"}'
Two vertices in the boundary are returned, as shown in figure 4:
Figure 4 Range Query
3. Integration with GeoServer
GeoServer is a java-based Open Source map server that supports various data sources, including shapefile and postgis. Neo4j spatial can be integrated with GeoServer in the form of plug-ins. The integration method is as follows:
- Uncompress neo4j-spatial-0.9-snapshot-server-plugin.zip and copy the jar packages except gt-* _ 8.0 to the geoserver/WEB-INF/lib folder.
- Copy all the jar files in neo4j/lib to the geoserver/WEB-INF/lib folder.
- Restart geoserver
By accessing the GeoServer address http: // localhost: 8080/geoserver/web/, we can see that, as shown in-5, neo4j can serve as the back end of geoserver and provide the map service.
Figure 5 integrate neo4j with geoserver
However, geoserver cannot display the layer in the published database. (System environment: Ubuntu 12.04, Spatial 0.9, Neo4j 1.8M6, Geoserver 2.1.1)
It is said to be a geoserver bug and will be fixed soon. Https://github.com/neo4j/spatial/issues/57
The next lecture will focus on a graph database Titan Based on HBase.
References
[17] Server Installation http://docs.neo4j.org/chunked/stable/server-installation.html
[18] Jetty http://jetty.codehaus.org/jetty/
[19] Server Configuration http://docs.neo4j.org/chunked/stable/server-configuration.html
[20] cURL http://curl.haxx.se/
[21] Well-known text http://en.wikipedia.org/wiki/Well-known_text