Permalink
Browse files

Update examples to show easier index instantiation with new index cla…

…sses. #20

Also, add an example of full-text index querying.
  • Loading branch information...
1 parent 8f880ec commit 6f649706ff853970752a188568a0e379490c4b3b @jadell committed Dec 10, 2011
Showing with 58 additions and 10 deletions.
  1. +2 −2 examples/bacon.php
  2. +2 −2 examples/cypher.php
  3. +2 −2 examples/directions.php
  4. +2 −2 examples/gremlin.php
  5. +48 −0 examples/indexing.php
  6. +2 −2 examples/widgets.php
View
@@ -2,7 +2,7 @@
<?php
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
- Everyman\Neo4j\Index,
+ Everyman\Neo4j\Index\NodeIndex,
Everyman\Neo4j\Relationship,
Everyman\Neo4j\Node;
error_reporting(-1);
@@ -42,7 +42,7 @@ function loaderTestAutoloader($sClass)
$transport = new Transport();
$client = new Client($transport);
-$actors = new Index($client, Index::TypeNode, 'actors');
+$actors = new NodeIndex($client, 'actors');
// Initialize the data
if ($cmd == 'init') {
View
@@ -2,7 +2,7 @@
<?php
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
- Everyman\Neo4j\Index,
+ Everyman\Neo4j\Index\NodeIndex,
Everyman\Neo4j\Relationship,
Everyman\Neo4j\Node,
Everyman\Neo4j\Cypher;
@@ -41,7 +41,7 @@ function loaderTestAutoloader($sClass)
$transport = new Transport();
$client = new Client($transport);
-$actors = new Index($client, Index::TypeNode, 'actors');
+$actors = new NodeIndex($client, 'actors');
// Initialize the data
if ($cmd == 'init') {
View
@@ -2,7 +2,7 @@
<?php
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
- Everyman\Neo4j\Index,
+ Everyman\Neo4j\Index\NodeIndex,
Everyman\Neo4j\Path,
Everyman\Neo4j\PathFinder,
Everyman\Neo4j\Relationship,
@@ -52,7 +52,7 @@ function loaderTestAutoloader($sClass)
$transport = new Transport();
$client = new Client($transport);
-$intersections = new Index($client, Index::TypeNode, 'intersections1');
+$intersections = new NodeIndex($client, 'intersections1');
$inters = array(
'A'=>null,
View
@@ -2,7 +2,7 @@
<?php
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
- Everyman\Neo4j\Index,
+ Everyman\Neo4j\Index\NodeIndex,
Everyman\Neo4j\Relationship,
Everyman\Neo4j\Node,
Everyman\Neo4j\Gremlin;
@@ -40,7 +40,7 @@ function loaderTestAutoloader($sClass)
$transport = new Transport();
$client = new Client($transport);
-$actors = new Index($client, Index::TypeNode, 'actors');
+$actors = new NodeIndex($client, 'actors');
// Initialize the data
if ($cmd == 'init') {
View
@@ -0,0 +1,48 @@
+#!/usr/bin/env php
+<?php
+spl_autoload_register(function ($sClass)
+{
+ $sLibPath = __DIR__.'/../lib/';
+ $sClassFile = str_replace('\\',DIRECTORY_SEPARATOR,$sClass).'.php';
+ $sClassPath = $sLibPath.$sClassFile;
+ if (file_exists($sClassPath)) {
+ require($sClassPath);
+ }
+});
+
+use Everyman\Neo4j\Transport,
+ Everyman\Neo4j\Client,
+ Everyman\Neo4j\Index\NodeIndex,
+ Everyman\Neo4j\Index\RelationshipIndex,
+ Everyman\Neo4j\Index\NodeFulltextIndex,
+ Everyman\Neo4j\Node,
+ Everyman\Neo4j\Batch;
+
+$client = new Client();
+
+$actorIndex = new NodeIndex($client, 'actors');
+$roleIndex = new RelationshipIndex($client, 'roles');
+$plotIndex = new NodeFulltextIndex($client, 'plots');
+$plotIndex->save();
+
+$leslie = $client->makeNode()
+ ->setProperty('name', 'Leslie Nielsen')
+ ->save();
+
+$airplane = $client->makeNode()
+ ->setProperty('title', 'Airplane')
+ ->save();
+
+$rumack = $leslie->relateTo($airplane, 'PLAYED')
+ ->setProperty('character', 'Dr. Rumack')
+ ->save();
+
+$actorIndex->add($leslie, 'name', $leslie->getProperty('name'));
+$roleIndex->add($rumack, 'character', $rumack->getProperty('character'));
+$plotIndex->add($airplane, 'synopsis', 'An airplane crew takes ill. Surely the only person capable of landing the plane is an ex-pilot afraid to fly. But don\'t call him Shirley.');
+
+echo $actorIndex->queryOne('name:Leslie*')->getProperty('name') . "\n";
+echo $roleIndex->queryOne('character:*u*')->getProperty('character') . "\n";
+echo $plotIndex->queryOne('synopsis:lend~0.2')->getProperty('title') . "\n";
+
+
View
@@ -2,7 +2,7 @@
<?php
use Everyman\Neo4j\Transport,
Everyman\Neo4j\Client,
- Everyman\Neo4j\Index,
+ Everyman\Neo4j\Index\NodeIndex,
Everyman\Neo4j\Path,
Everyman\Neo4j\PathFinder,
Everyman\Neo4j\Relationship,
@@ -53,7 +53,7 @@ function loaderTestAutoloader($sClass)
$transport = new Transport();
$client = new Client($transport);
-$partsIndex = new Index($client, Index::TypeNode, 'parts3');
+$partsIndex = new NodeIndex($client, 'parts3');
$parts = array('widget','gadget','gizmo');
$stores = array("Bob's Old Houseware","Mainstreet Hardware","Nutz N' Boltz", "Doodad Emporium");

0 comments on commit 6f64970

Please sign in to comment.