我正在创建一个新的Neo4j数据库.我有一个名为USER的 node 类型,我想要一个关于USER IdentifierEmailAddress属性的索引.当数据库是新的时,如何建立索引呢?我注意到,在ne4j.properties文件中似乎支持创建索引.但是,当我将这些设置为这样时

# Autoindexing

# Enable auto-indexing for nodes, default is false
node_auto_indexing=true

# The node property keys to be auto-indexed, if enabled
node_keys_indexable=EmailAddress,Identifier

并添加一个 node 并执行查询以查找我知道存在的标识符

START n=node:Identifier(Identifier = "USER0")
RETURN n;

然后我就会得到一个

MissingIndexException: Index `Identifier` does not exist

如何创建索引并在START查询中使用它?我只想使用配置文件和密码来实现这一点.也就是说,目前我只在电动工具控制台上玩.

推荐答案

将以下内容添加到ne4j.properties文件

# Autoindexing

# Enable auto-indexing for nodes, default is false
node_auto_indexing=true

# The node property keys to be auto-indexed, if enabled
node_keys_indexable=EmailAddress,Identifier

为 node 创建自动索引

neo4j-sh (0)$ index --create node_auto_index -t Node

判断它们是否存在

neo4j-sh (0)$ index --indexes

应该回来

Node indexes:
node_auto_index

查询时,请使用以下语法指定索引

start a = node:node_auto_index(Identifier="USER0")
return a;

因为 node 是自动索引的,所以索引的名称是node_auto_index

这条信息来自this page分下方的一条 comments

Update

如果您想为当前数据编制索引,而该数据在自动索引打开之前就已存在(其中Property_Name是索引的名称)

START nd =node(*) 
WHERE has(nd.Property_Name)
WITH nd
SET nd.Property_Name = nd.Property_Name
RETURN count(nd);

Database相关问答推荐

如何自动更新不同的数据库?

如何在同一个表的派生部分引用主键?

将数据库/后端添加到 android 应用程序

这到底是做什么的 Class.forName("com.mysql.jdbc.Driver").newInstance();

Android SQLiteno such table异常

需要未提供的参数@ID?

repeating groups是什么意思?

SQL 历史(history)表设计

ORM vs 传统数据库查询,它们的字段是什么?

如何从 MySQL 行中修剪前导和尾随引号?

什么是表前缀?

数据库设计—应该避免一对一的关系吗?

应用程序用户应该是数据库用户吗?

处理多个表的最佳实践

在数据库中存储业务逻辑

在 PostgreSQL 中索引空值

存储信用卡号 - PCI?

如何修复 Postgres 上过时的 postmaster.pid 文件?

在一个查询中使用 group by 计算多列

xampp phpmyadmin,格式参数不正确