Пример #1
0
 private function queryFulltext($query)
 {
     $index = new Neo4j\Index\NodeFulltextIndex($this->client, 'full_text');
     // Index needs to be saved just in case this is the first time it's being used.
     // Otherwise config errors will be thrown by Neo4j.
     // See: https://github.com/jadell/neo4jphp/issues/77
     $index->save();
     // Use proximity matching.
     // See: http://www.lucenetutorial.com/lucene-query-syntax.html
     $client_nodes = $index->query('full_text:"' . $this->escapeQuery($query) . '"~100');
     return $client_nodes;
 }
Пример #2
0
#!/usr/bin/env php
<?php 
use Everyman\Neo4j\Client, Everyman\Neo4j\Index\NodeIndex, Everyman\Neo4j\Index\RelationshipIndex, Everyman\Neo4j\Index\NodeFulltextIndex, Everyman\Neo4j\Node, Everyman\Neo4j\Batch;
require_once 'example_bootstrap.php';
$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";
Пример #3
0
 public function delete()
 {
     $client_node = $this->getClientObject();
     // Remove the full text index.
     $index = new Neo4j\Index\NodeFulltextIndex($this->client, 'full_text');
     $index->remove($client_node);
     $index->save();
     // Orphan the node.
     $client_edges = $client_node->getRelationships();
     if ($client_edges) {
         foreach ($client_edges as $client_edge) {
             $client_edge->delete();
         }
     }
     parent::delete();
 }