Neo4j:一步一步创建自动索引

编程入门 行业动态 更新时间:2024-10-26 14:32:22
本文介绍了Neo4j:一步一步创建自动索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在创建一个新的 Neo4j 数据库.我有一种名为 User 的节点,我想要一个关于用户 Identifier 和 EmailAddress 属性的索引.当数据库是新的时,如何设置索引?我注意到在 neo4j.properties 文件中似乎支持创建索引.但是,当我将这些设置为这样时

I am creating a new Neo4j database. I have a type of node called User and I would like an index on the properties of user Identifier and EmailAddress. How does one go setting up an index when the database is new? I have noticed in the neo4j.properties file there looks to be support for creating indexes. However when I set these as so

# 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

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

And add a node and do a query to find an Identifier that I know exists

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

然后我得到一个

MissingIndexException: Index `Identifier` does not exist

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

How do I create an index and use it in a start query? I only want to use config files and cypher to achieve this. i.e. at the present time I am only playing in the Power Tool Console.

推荐答案

在neo4j.properties文件中加入以下内容

Add the following to the neo4j.properties file

# 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

为节点创建自动索引

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

检查它们是否存在

neo4j-sh (0)$ index --indexes

应该回来

Node indexes: node_auto_index

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

When querying use the following syntax to specify the index

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

由于节点是自动索引的,所以索引的名称是node_auto_index

As the node is auto indexed the name of the index is node_auto_index

此信息来自此页面底部的评论

更新

如果您想索引在自动索引打开之前存在的当前数据(其中 Property_Name 是索引的名称)

In case you want to index your current data which was there before automatic indexing was turned on (where Property_Name is the name of your index)

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

更多推荐

Neo4j:一步一步创建自动索引

本文发布于:2023-05-28 06:51:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/315050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:索引   Neo4j

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!