【问题标题】:creating a named index on neo4j在 neo4j 上创建命名索引
【发布时间】:2014-10-15 11:07:52
【问题描述】:

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

【问题讨论】:

    标签: php neo4j neo4jphp


    【解决方案1】:

    嗯,here is the documentation on neo4j indexeshere's the relevant docs for php

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

    $nameIndex = new Everyman\Neo4j\Index\NodeIndex($client, 'actors');
    $nameIndex->save();
    

    【讨论】:

    • 但是,如果我已经有索引,但没有像你刚才展示的那样命名索引,我该如何搜索内容,可以创建服务器上的索引实例吗,我想我是让自己清楚。
    • 一般来说,如果你创建一个索引,那么你可以使用 cypher,它会自动利用索引。命名索引需要在密码start 子句中按名称调用。但是,如果您使用架构索引,则只需正常查询即可。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-04
    • 1970-01-01
    • 1970-01-01
    • 2013-05-10
    相关资源
    最近更新 更多