Skip to content

Instantly share code, notes, and snippets.

View peterneubauer's full-sized avatar

Peter Neubauer peterneubauer

View GitHub Profile
@peterneubauer
peterneubauer / GoT.sql
Created July 11, 2012 13:12
The Game of Thrones Graph
start westeros=node(0)
set westeros.name = "Westeros"
create targaryen={house:"Targaryen"},
stark={house:"Stark"},
lannister={house:"Lannister"},
baratheon={house:"Baratheon"},
tully={house:"Tully"}
@peterneubauer
peterneubauer / gist:3347559
Created August 14, 2012 08:31
Python basic index search
from neo4j import GraphDatabase
# Create db
db = GraphDatabase('db')
with db.transaction:
noun_id = 1
#-----1-----------------
#first creating the index, reference node and storing it...
noun_index = db.node.indexes.create('noun_idx')
@peterneubauer
peterneubauer / SpatialOsmImport.java
Created September 15, 2012 19:46 — forked from mavenik/SpatialOsmImport.java
Neo4j Spatial Import
/**
* Copyright (c) 2010-2012 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
@peterneubauer
peterneubauer / gist:3911804
Created October 18, 2012 13:28
Neo4j auto index and batch inserter
public void shouldCreateAutoIndex() throws Exception
{
String path = new File( PATH, "10" ).getAbsolutePath();
BatchInserter inserter = new BatchInserterImpl( path );
BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProviderNewImpl(
inserter );
BatchInserterIndex index = provider.nodeIndex( "node_auto_index", EXACT_CONFIG );
long id = inserter.createNode( null );
Map<String, Object> props = new HashMap<String, Object>();
@peterneubauer
peterneubauer / Cineasts.cql
Last active October 12, 2015 19:48
Cineasts Cypher script
begin
start root=node(0)
create unique
root-[:GENRES]->({type:'GENRES'}),
root-[:MOVIES]->({type:'MOVIES'}),
root-[:PEOPLE]->({type:'PEOPLE'});
{:actors=>[{:role=>"Jake Sully", :name=>"Sam Worthington", :id=>65731}, {:role=>"Neytiri", :name=>"Zoe Saldana", :id=>8691}, {:role=>"Dr. Grace Augustine", :name=>"Sigourney Weaver", :id=>10205}, {:role=>"Col. Quaritch", :name=>"Stephen Lang", :id=>32747}, {:role=>"Trudy Chacon", :name=>"Michelle Rodriguez", :id=>17647}, {:role=>"Norm Spellman", :name=>"Joel Moore", :id=>59231}, {:role=>"Selfridge", :name=>"Giovanni Ribisi", :id=>1771}, {:role=>"Moha", :name=>"CCH Pounder", :id=>30485}, {:role=>"TsuTey", :name=>"Laz Alonso", :id=>10964}, {:role=>"Eytukan", :name=>"Wes Studi", :id=>15853}, {:role=>"Dr. Max Patel", :name=>"Dileep Rao", :id=>95697}, {:role=>"Lyle Wainfleet", :name=>"Matt Gerald", :id=>98215}, {:role=>"Samson Pilot", :name=>"Dean Knowsley", :id=>98216}], :movie_id=>19995, :directors=>[{:name=>"James Cameron", :id=>2710}], :tagline=>"Enter
start joe=node:node_auto_index(name = "Joe") match joe-[:knows]->friend-[:knows]->friend_of_friend where not(joe-[:knows]-friend_of_friend) return collect(friend.name), friend_of_friend.name
# Default values for the low-level graph engine
#neostore.nodestore.db.mapped_memory=25M
#neostore.relationshipstore.db.mapped_memory=50M
#neostore.propertystore.db.mapped_memory=90M
#neostore.propertystore.db.strings.mapped_memory=130M
#neostore.propertystore.db.arrays.mapped_memory=130M
# Autoindexing
# Enable auto-indexing for nodes, default is false
@peterneubauer
peterneubauer / gist:5822727
Last active December 18, 2015 17:59
Minimal Spatial setup
package spatial;
import com.vividsolutions.jts.geom.Coordinate;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.geotools.map.Layer;
import org.neo4j.collections.rtree.Envelope;
import org.neo4j.collections.rtree.SpatialIndexReader;
= Neo4j und Javascript =
// console
[source,cypher]
----
CREATE (movie:Movie {title:"Matrix", year: 1999}),
(movie)<-[:ACTED_IN {role:"Neo"}]-(:Actor {name:"Keanu Reeves", age: 48}),
(movie)<-[:DIRECTED]-(:Director {name:"Wachowski"}),
(movie)<-[:RATED {stars: 5}]-(:User {login:"Michael"})
== The Neo4j GraphGist Console. ==
This is a sample GraphGist explaining some of the base concepts of sharing graphs using http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html[the Cypher query language].
[source,cypher]
----
CREATE ({name:'you'})-[:SEE]->({name:'This GraphGist'})-[:FORK_ON_GITHUB]->(your_gistfile{name:'Your Gist'})
CREATE (your_gistfile)-[:INSERT_ID_HERE]->({name:'Your GraphGist'})
----