cypher

Neo4j: Native Java API(or equivalent cypher query) in Spring Data Neo4j

感情迁移 提交于 2019-12-24 11:35:19
问题 I was experimenting with Neo4j embedded-db in the past few days for a DEMO and was thoroughly impressed with the Native Java API's for indexing, lucene queries and even managed to do fuzzy search. I then decided to take this POC to production with Spring Data Neo4j 4.0 but ran into issues with Cypher queries and fuzzy search. My domain class "Team" looks like this: @NodeEntity public class Team { @GraphId Long nodeId; /** The team name. */ @Indexed(indexType = IndexType.FULLTEXT,indexName =

How can I get an exclusive subgraph from a vertex?

本小妞迷上赌 提交于 2019-12-24 10:56:15
问题 I've recently had to change from using Cypher to Gremlin and I'm trying to convert a query that allowed a user to 'delete' a node and all of the subgraph nodes that would be affected by this. It wasn't actually removing nodes but just adding a 'DELETED' label to the affected nodes. I can get a subgraph in Gremlin using: g.V(nodeId).repeat(__.inE('memberOf').subgraph('subGraph').outV()).cap('subGraph') but this doesn't take into account any nodes in the subgraph that might have a route back

Is it possible to get the shortest path with traversal cost by using Cypher or Gremlin?

◇◆丶佛笑我妖孽 提交于 2019-12-24 10:53:46
问题 I know it is possible to get the shortest path of minimum number of nodes by using Cypher and Gremlin? How about getting a path with minimum traversal cost? One of the example I can think of is the bus route. Some routes may have less bus stops (nodes) but need longer time (cost) to travel from one stop to another, some are reverse. Is it possible to get the shortest path with minimum travel time by using Cypher or Gremlin? 回答1: See this other question for more on shortest paths. In answer to

Neo4j Cypher query null or IN

霸气de小男生 提交于 2019-12-24 10:46:19
问题 I have a following cypher query: MATCH (parentD)-[:CONTAINS]->(childD:Decision)-[ru:CREATED_BY]->(u:User) WHERE id(parentD) = {decisionId} RETURN ru, u, childD SKIP 0 LIMIT 100 Decision entity can belong to 0..N Tenant objects @NodeEntity public class Decision { private final static String BELONGS_TO = "BELONGS_TO"; @Relationship(type = BELONGS_TO, direction = Relationship.OUTGOING) private Set<Tenant> tenants = new HashSet<>(); .... } I need to extend the Cypher query above in order to

Neo4j Cypher manual relationship index, APOC trigger and data duplication

旧时模样 提交于 2019-12-24 09:52:29
问题 I have the following query that uses plain relationship operations for node filtering: MATCH (dg:DecisionGroup)-[:CONTAINS]->(childD:Decision) WHERE dg.id = 1 MATCH (childD)-[relationshipValueRel2:HAS_VALUE_ON]->(filterCharacteristic2:Characteristic) WHERE filterCharacteristic2.id = 2 WITH relationshipValueRel2, childD, dg WHERE (ANY (id IN [".NET"] WHERE id IN relationshipValueRel2.value )) RETURN childD.name which returns only one node(as it was expected): "Candidate1" PROFILE output: I'd

NEO4J Cypher Query: Multiple Aggregates

 ̄綄美尐妖づ 提交于 2019-12-24 08:56:54
问题 Sample Data Sample Query: At the end of this post Objective: Searches similar to 'who knows exactly 2 Cust and works at 1 company' Step 1 : I just did a print of the number of connected Cust and Comp and its all good till now MATCH (from:Cust), (a:Cust), (b:Comp), p1=((from)-[r1]-(a)), p2=((from)-[r2]-(b)) WITH from, count(DISTINCT a) as knows, count(DISTINCT b) as works RETURN from.title, knows, works Step 2 : I went and added WHERE clause to filter the count, so far so good MATCH (from:Cust

Neo4j: Speed up Relationship matching by property inequality

我的未来我决定 提交于 2019-12-24 08:48:47
问题 I'm using Neo4j 3.0.5. My query looks as follows: MATCH (cd:ConnectionDay)-[c:Connection]->() WHERE id(cd)= { id } AND c.departure <= { departure } RETURN c In my graph, the number of Connection relations is very high and I'm looking for a way to speed up the retrieval. Is there a way to create an index for the departure property? I'm using the Embedded Java API anyway, so solutions that aren't using Cypher are ok, too. 回答1: Aside: It is not recommended that you use native neo4j IDs to find

Neo4j grouping with two relationships

僤鯓⒐⒋嵵緔 提交于 2019-12-24 07:58:49
问题 I have a chart that will represent hierarchy for nodes like this one. Lets say that this one is representing the complete hierarchy but I also need to create intermediate result by grouping at different levels. Suppose I'm requesting data for node A. I wish to regroup nodes at the nearest Group relationship. I'd to get something like this: Basically users will be allowed to associate nodes to group and I need to represent the data in the convenient way to display an Org Chart. I don't know

Neo4j Cypher comparing dates in Cypher query

好久不见. 提交于 2019-12-24 07:56:37
问题 Right now I'm designing a system with Neo4j database where I have to be able to have a query check if a Date property in a node is before, equal or after the provided Date . How should I store the Date inside of Neo4j Node property to be able to do a comparison with Cypher query based for example on simple operators like == , > , < Is it okay to store Date like Long timestamp ? Will it work this way ? If no, please suggest a better decision. UPDATED Queries I have tried with no luck: MATCH

Neo4j long lasting query to be split/executed in smaller chunks?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-24 07:46:41
问题 My import.csv creates many nodes and merging creates a huge cartesian product and runs in a transaction timeout since the data has grown so much. I've currently set the transaction timeout to 1 second because every other query is very quick and is not supposed to take any longer than one second to finish. Is there a way to split or execute this specific query in smaller chunks to prevent a timeout? Upping or disabling the transaction timeout in the neo4j.conf is not an option because the