Git Product home page Git Product logo

import_maxmind_sproc's Introduction

Import Maxmind Stored Procedure

Import the MaxMind Cities Database into Neo4j using a Stored Procedure

This project requires Neo4j 3.3.x

Instructions

This project uses maven, to build a jar-file with the procedure in this project, simply package the project with maven:

mvn clean package

This will produce a jar-file, target/importer-1.0-SNAPSHOT.jar, that can be copied to the plugin directory of your Neo4j instance.

cp target/importer-1.0-SNAPSHOT.jar neo4j-enterprise-3.3.1/plugins/.

Edit your Neo4j/conf/neo4j.conf file by adding this line:

dbms.security.procedures.unrestricted=com.maxdemarzi.*    

(Re)start Neo4j

Create the schema:

CALL com.maxdemarzi.schema.generate;

Import the data (ip4 data not included in repo):

CALL com.maxdemarzi.import.locations("/Users/maxdemarzi/Projects/import_maxmind_sproc/src/main/resources/data/GeoLite2-City-Locations-en.csv");

CALL com.maxdemarzi.import.ip4("/Users/maxdemarzi/Projects/import_maxmind_sproc/src/main/resources/data/GeoLite2-City-Blocks-IPv4.csv");

If using Windows you must escape the slashes like so:

CALL com.maxdemarzi.import.locations('C:\\Users\\maxdemarzi\\Projects\\import_maxmind_sproc\\src\\main\\resources\\data\\GeoLite2-City-Locations-en.csv');    

If you are using Neo4j 3.4 or later you can all add a spatial index:

CREATE INDEX ON :City(location);

and populate it with:

MATCH (c:City)
SET c.location = point({latitude: c.latitude, longitude: c.longitude, crs: 'WGS-84'});

Then you will be able to do spatial queries like:

MATCH (c:City)-[:IN_LOCATION]->(s:State), (c2:City)
WHERE c.name = "Union City"
  AND s.name = "California"
  AND distance(c.location, c2.location) <= 10000
RETURN c2.name, c2.latitude, c2.longitude, distance(c.location, c2.location)    

This product includes GeoLite2 data created by MaxMind, available from http://www.maxmind.com.

import_maxmind_sproc's People

Contributors

maxdemarzi avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.