Neo的全球指数 [英] Global indexes in Neo

查看:91
本文介绍了Neo的全球指数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们公司中,我们通过Web服务将ID列表返回给客户.这些ID在整个系统中都是唯一的.他们调用其他传递ID的Web服务.我们并不总是知道收到的ID的标签.

In our company, we return a list of IDs to clients through a web service. The IDs are unique across the system. They invoke other web services passing the IDs. We don't always know the label of the ID we receive.

这不执行:

MATCH(n {id:{my_id}) ...

虽然我们几乎对所有标签类型都有索引,但是此查询没有标签,因此就我所知,它不使用索引.

While we have indexes on almost all label types, this query has no label and as thus does not use an index as far as I can tell.

在所有节点上添加一个名为"GLOBAL"(或其他名称)的标签是一个坏主意,以便我们可以对GLOBAL.id施加唯一约束吗?那么上面的查询可能是

Is it a bad idea to add a label called "GLOBAL" (or whatever) to all nodes so we can put a unique constraint on GLOBAL.id? Then the query above could be

MATCH(n: GLOBAL{id:{my_id}})...

表现不错.

还有另一种方法吗?

推荐答案

您可以使用Neo4j的内部ID来标识您的资源,但这不是最佳实践,请参见

You can use Neo4j's internal ID to identify your resources, but it's not best practice, see Should we use the Neo4J internal id?

这是使用neo4j的内部ID获取节点的方法:

This is how to get a node using his neo4j's internal id:

START n=node({my_id}) return n

它确实比MATCH子句快,因为这里您的查询直接从一个节点开始,并且不需要过滤跨越一组节点的属性,因为它是内部ID.

It's really faster than a MATCH clause, because here your query directly starts with one node, and doesn't have to filter a property accross a set of nodes, because it's internal id.

如果您可以处理内部ID限制,那就是您正在寻找的解决方案.

If you can handle the internal id limitations, it's the solution you are looking for.

这篇关于Neo的全球指数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆