Neo4j关系指数 - 搜索关系属性 [英] Neo4j Relationship Index - Search on relationship property

查看:172
本文介绍了Neo4j关系指数 - 搜索关系属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有以下结构的neo4j图。

I've got a neo4j graph with the following structure.

(账户)--- [交易] ---(账户)

(Account) ---[Transaction]--- (Account)

交易是neo4j关系,账户是节点。

Transaction is a neo4j relationship and Account is a node.

每笔交易都设置了各种属性,例如交易ID ,金额,日期和各种其他银行信息。

There are set various properties on each transaction, such as the transaction ID, amount, date, and various other banking information.

我可以按帐户ID运行搜索,并且返回正常。但是,当我按事务ID搜索时,neo4J搜索整个图形而不是使用索引,搜索失败。

I can run a search by Account id, and it returns fine. However when I search by transaction ID, neo4J searches the entire graph instead of using index, and the search fails.

我使用 org创建了索引。对于Account.number和Transaction.txid,neo4j.unsafe.batchinsert.BatchInserterImpl.createDeferredSchemaIndex()。该索引似乎适用于帐户(节点)搜索,但不适用于事务(关系)搜索。 (我也为节点和关系启用了自动索引,但它没有改变的东西)

I created indexes using org.neo4j.unsafe.batchinsert.BatchInserterImpl.createDeferredSchemaIndex() for both Account.number and Transaction.txid. The index seems to function for Account (node) searches but not for Transaction (relationship) searches. (I have also enabled auto index for node and relationship, but it doesnt change things)

我认为不支持关系属性的索引,所以考虑制作中间用于保存属性信息的节点。但是,如果可能的话,我更愿意坚持我原来的设计。

I'm thinking that indexing on relationship properties is not supported, so considering making intermediate nodes to hold property information. However, I'd prefer to stick to my original design if possible.

知道如何继续吗?

推荐答案

您可以使用旧索引自动索引以建立索引关系。模式索引不支持索引关系。

You can use legacy indexes or auto indexes to index relationships. Schema indexes do not support indexing relationships.

原因是:通常,您使用use节点对域中的#thing#或#entities#进行建模。关系将您的世界连接起来并将节点置于语义上下文中。在遵循该模型时,您通常不需要索引关系,因为您的查询总是从#thing#开始,它总是一个节点。

The reason for that: Typically you use use nodes to model the #things# or #entities# in your domain. Relationship wire up your world and put the nodes into a semantic context. When following that model you typically don't have to index relationships since your queries always start at a #thing# which is always a node.

在您的模型中,您应该重新思考建模,我想这可能是有意义的

In your model, you should rethink modelling, I guess it could make sense to have

 (account)-[:send]->(transaction)-[:to]->(account).

因此,交易本身就是一个东西,因此成为节点。

So transactions are a thing on its own and therefore become nodes.

这篇关于Neo4j关系指数 - 搜索关系属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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