Do we need to index on relationship properties to ensure that Neo4j will not search through all relationships

Steve P.

To clarify, let's assume that I have a relationship type: "connection." Connections has a property called: "typeOfConnection," which can take on values in the domain:

{"GroupConnection", "FriendConnection", "BlahConnect"}.

When I query, I may want to qualify connection with one of these types. While there are not many types, there will be millions of connections with each property type.

Do I need to put an index on connection.typeOfConnection in order to ensure that all connections will not be traversed?

If so, I have been unable to find a simple cypher statement to do this. I've seen some stuff in the documentation describing how to do this in Java, but I'm interacting with Neo using Py2Neo, so it would be wonderful if there was a cypher way to do this.

Kenny Bastani

This is a mixed granularity property graph data model. Totally fine, but you need to replace your relationship qualifiers with intermediate nodes. To do this, replace your relationships with one type node and 2 relationships so that you can perform indexing.

Your model has a graph with a coarse-grained granularity. The opposite extreme is referred to as fine-grained granularity, which is the foundation of the RDF model. With property graph you'll need to use nodes in place of relationships that have labels applied by their type if you're going to do this kind of coarse-grained graph.

For instance, let's assume you have:

MATCH (thing1:Thing { id: 1 })-->(:Connection { type: "group" }),
      (group)-->(thing2:Thing)
RETURN thing2

Then you can index on the label Connection by property type.

CREATE INDEX ON :Connection(type)

This allows you the flexibility of not typing your relationships if your application requires dynamic types of connections that prevent you from using a fine-grained granularity.

Whatever you do, don't work around your issue by dynamically generating typed relationships in your Cypher queries. This will prevent your query templates from being cached and decrease performance. Either type all your relationships or go with the intermediate node I've recommended above.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Neo4j: how do I delete all duplicate relationships in the database through cypher?

From Dev

Neo4j Relationship Index - Search on relationship property

From Dev

Why do we need "Relationships" between tables at all?

From Dev

Neo4j: Iterate through collection of relationships and set property to index

From Dev

Neo4j: Iterate through collection of relationships and set property to index

From Dev

Neo4j Properties on relationship

From Dev

Order by relationship properties neo4j

From Dev

Relationship properties in Neo4j

From Dev

Relationship properties in Neo4j

From Dev

How to delete all nodes that do not have any relationships - neo4j/cypher

From Dev

neo4j nodejs strength or properties's relationship modified : how to do it?

From Dev

Why do we need explicit relationships in grails?

From Dev

how do i delete all relationship of a specific type in Neo4j

From Dev

how do i delete all relationship of a specific type in Neo4j

From Dev

Neo4j Design: When to use Properties for Relationships

From Dev

neo4j search nodes, relationships contains *string*

From Dev

Neo4j wildcard search on existing relationships?

From Dev

Fastest way to get all Neo4j nodes and relationships?

From Dev

Select nodes that has all relationships in Neo4j

From Dev

Neo4j, get all relationships between a set of nodes

From Dev

Neo4j - Delete 2 related nodes with all of their relationships

From Dev

neo4j ogm returns not all relationships

From Dev

Load CSV into neo4j does not fill in relationship properties

From Dev

How to add multiple value for a relationship properties in neo4j?

From Dev

neo4j - labels vs properties vs relationship + node

From Dev

Neo4j gem - Updating relationship properties method

From Dev

Neo4j graph database relationship with properties

From Dev

How to add multiple value for a relationship properties in neo4j?

From Dev

Load CSV into neo4j does not fill in relationship properties

Related Related

  1. 1

    Neo4j: how do I delete all duplicate relationships in the database through cypher?

  2. 2

    Neo4j Relationship Index - Search on relationship property

  3. 3

    Why do we need "Relationships" between tables at all?

  4. 4

    Neo4j: Iterate through collection of relationships and set property to index

  5. 5

    Neo4j: Iterate through collection of relationships and set property to index

  6. 6

    Neo4j Properties on relationship

  7. 7

    Order by relationship properties neo4j

  8. 8

    Relationship properties in Neo4j

  9. 9

    Relationship properties in Neo4j

  10. 10

    How to delete all nodes that do not have any relationships - neo4j/cypher

  11. 11

    neo4j nodejs strength or properties's relationship modified : how to do it?

  12. 12

    Why do we need explicit relationships in grails?

  13. 13

    how do i delete all relationship of a specific type in Neo4j

  14. 14

    how do i delete all relationship of a specific type in Neo4j

  15. 15

    Neo4j Design: When to use Properties for Relationships

  16. 16

    neo4j search nodes, relationships contains *string*

  17. 17

    Neo4j wildcard search on existing relationships?

  18. 18

    Fastest way to get all Neo4j nodes and relationships?

  19. 19

    Select nodes that has all relationships in Neo4j

  20. 20

    Neo4j, get all relationships between a set of nodes

  21. 21

    Neo4j - Delete 2 related nodes with all of their relationships

  22. 22

    neo4j ogm returns not all relationships

  23. 23

    Load CSV into neo4j does not fill in relationship properties

  24. 24

    How to add multiple value for a relationship properties in neo4j?

  25. 25

    neo4j - labels vs properties vs relationship + node

  26. 26

    Neo4j gem - Updating relationship properties method

  27. 27

    Neo4j graph database relationship with properties

  28. 28

    How to add multiple value for a relationship properties in neo4j?

  29. 29

    Load CSV into neo4j does not fill in relationship properties

HotTag

Archive