use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestRecovery method newGraphDbService.
private GraphDatabaseService newGraphDbService() {
String path = getDbPath();
Neo4jTestCase.deleteFileOrDirectory(new File(path));
return new EmbeddedGraphDatabase(path);
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class TestLuceneBatchInsert method testNumericValues.
@Test
public void testNumericValues() {
String path = new File(PATH, "7").getAbsolutePath();
BatchInserter inserter = new BatchInserterImpl(path);
BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(inserter);
BatchInserterIndex index = provider.nodeIndex("mine", EXACT_CONFIG);
long node1 = inserter.createNode(null);
index.add(node1, map("number", numeric(45)));
long node2 = inserter.createNode(null);
index.add(node2, map("number", numeric(21)));
assertContains(index.query("number", newIntRange("number", 21, 50, true, true)), node1, node2);
provider.shutdown();
inserter.shutdown();
GraphDatabaseService db = new EmbeddedGraphDatabase(path);
Node n1 = db.getNodeById(node1);
Node n2 = db.getNodeById(node2);
Index<Node> idx = db.index().forNodes("mine");
assertContains(idx.query("number", newIntRange("number", 21, 45, false, true)), n1);
db.shutdown();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class RelatedNodesQuestionTest method question5346011.
@Test
public void question5346011() {
GraphDatabaseService service = new EmbeddedGraphDatabase("target/soquestion-test");
Transaction transaction = service.beginTx();
try {
RelationshipIndex index = service.index().forRelationships("exact");
// ...creation of the nodes and relationship
Node node1 = service.createNode();
Node node2 = service.createNode();
String a_uuid = "xyz";
Relationship relationship = node1.createRelationshipTo(node2, DynamicRelationshipType.withName("related"));
index.add(relationship, "uuid", a_uuid);
// query
IndexHits<Relationship> hits = index.get("uuid", a_uuid, node1, node2);
assertEquals(1, hits.size());
transaction.success();
} finally {
transaction.finish();
}
service.shutdown();
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class Neo4jTestCase method setUpDb.
@BeforeClass
public static void setUpDb() throws Exception {
deleteFileOrDirectory(dbPath);
graphDb = new EmbeddedGraphDatabase(dbPath.getAbsolutePath());
}
use of org.neo4j.kernel.EmbeddedGraphDatabase in project graphdb by neo4j-attic.
the class AddRelToIndex method main.
public static void main(String[] args) {
String path = args[0];
String indexName = "myIndex";
GraphDatabaseService db = new EmbeddedGraphDatabase(path);
Index<Relationship> index = db.index().forRelationships(indexName);
Transaction tx = db.beginTx();
Node node = db.createNode();
Relationship relationship = db.getReferenceNode().createRelationshipTo(node, DynamicRelationshipType.withName("KNOWS"));
index.add(relationship, "key", "value");
tx.success();
tx.finish();
// Skip shutdown
}
Aggregations