0

我正在将 neo4j php 用于创建索引并将节点添加到它们的示例案例

$client = new Client();
$actors = new NodeIndex($client, 'actors');
$juhichawla = $client->makeNode()->setProperty('name', 'Juhi Chawla')->save();
$actors->add($juhichawla, 'name', $juhichawla->getProperty('name'));

我可以通过 REST API 查看数据来查看此索引

:GET /db/data/index/node/

{
  "actors": {
    "template": "http://localhost:7474/db/data/index/node/actors/{key}/{value}",
    "provider": "lucene",
    "type": "exact"
  }
}

现在我批量加载了许多演员,我是否也可以使用相同的索引来索引它们,我真的不知道如何为他们添加索引(演员的命名索引),我用来查找节点的 neo4jphp 代码仅当您为数据命名索引时才有用。

$from = 'shahrukh khan';
$client = new Client();
$actors = new NodeIndex($client, 'actors');

$fromNode = $actors->findOne('name', $from);        
f (!$fromNode) {
echo "$from not found\n";
exit(1);
}
4

1 回答 1

0

好吧,这里是 neo4j 索引的文档,这里是php 的相关文档

因此,该文档表明您的代码将如下所示:

$nameIndex = new Everyman\Neo4j\Index\NodeIndex($client, 'actors');
$nameIndex->save();
于 2014-10-15T13:58:20.437 回答