我正在将 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);
}