logo
down
shadow

neo4j query on number of matches in a set


neo4j query on number of matches in a set

By : user2949144
Date : November 16 2020, 06:23 AM
hope this fix your issue This query match for e.g. all contexts and optinally match contexts that contain two specific roots :
code :
MATCH (n:Context)
OPTIONAL MATCH (n)<-[:EXPRESSED_AS]-(r)
WHERE r.base_form = "cool" AND r.base_form = "hot"
WITH count(r) AS c, n
ORDER BY c DESC 
RETURN n, c


Share : facebook icon twitter icon
Possible to order an SQL query that matches with a REGEX by the number of matches found?

Possible to order an SQL query that matches with a REGEX by the number of matches found?


By : user3486214
Date : March 29 2020, 07:55 AM
I hope this helps . I found an UDF some time ago to do this. I'm really sorry I can't cite the source though.
code :
DELIMITER //

CREATE DEFINER=`root`@`localhost` FUNCTION `substrCount`(s VARCHAR(255), ss VARCHAR(255)) RETURNS tinyint(3) unsigned
    READS SQL DATA
BEGIN
    DECLARE count TINYINT(3) UNSIGNED;
    DECLARE offset TINYINT(3) UNSIGNED;
    DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s = NULL;

    SET count = 0;
    SET offset = 1;

    REPEAT
        IF NOT ISNULL(s) AND offset > 0 THEN
            SET offset = LOCATE(ss, s, offset);
            IF offset > 0 THEN
                SET count = count + 1;
                SET offset = offset + 1;
            END IF;
        END IF;
    UNTIL ISNULL(s) OR offset = 0 END REPEAT;

    RETURN count;
END

DELIMITER ;
Neo4j PHP performing a query that matches a node property to a string variable

Neo4j PHP performing a query that matches a node property to a string variable


By : Nurdiana
Date : March 29 2020, 07:55 AM
wish helps you Please use parameters and not string concatenation!
MATCH (n.Keywords) WHERE n.kw =~ {regexp} RETURN n
Neo4j query in neo4j-sh returns the right number of rows while query_as in RoR returns double the number of rows

Neo4j query in neo4j-sh returns the right number of rows while query_as in RoR returns double the number of rows


By : user3128121
Date : March 29 2020, 07:55 AM
Does that help I'd expect 6 rows, not 8, but maybe I'm overlooking something. Doesn't matter, really. Instead of returning post and comment independently, try returning post and collections of comment. You don't need query_as, either, you can do it purely through QueryProxy.
code :
result = Post.as(:post).comments(:comment).pluck(:post, 'collect(comment)')
result.each do |pair|
  post = pair[0]
  comments_array = pair[1]
  comments_array.each do |comment|
    # do things
  end
end
Neo4j - Speeding up a query with optional matches and collects (slow)

Neo4j - Speeding up a query with optional matches and collects (slow)


By : Jonathan Alexander
Date : March 29 2020, 07:55 AM
fixed the issue. Will look into that further Does anyone have any ideas on how to speed this up? The optional matches are slowing down the query, but I don't know another way to achieve the same thing. , I don't know if this query will be better, but you can test it :
code :
MATCH (u:User {id: [ID-HERE]})
RETURN
u.id AS id,
u.firstName AS firstName,
u.lastName AS lastName,
u.createdAt AS createdAt,
[(u)-[:FOLLOWS]->(u1) | u1.id] AS  usersFollowing,
[(u)-[:HAS_PROFESSION]->(p) | p.id] AS professionIds,
[(u)-[:HAS_SKILL]->(s) | s.id] AS skillsId,
[(u)-[:HAS_INDUSTRY]->(i) | i.name] AS industries,
[(u)-[:HAS_EXPERIENCE]->(e) | e.name] AS experiences
Neo4j Cypher query to create single relationship among multiple matches with a hierarchical format

Neo4j Cypher query to create single relationship among multiple matches with a hierarchical format


By : user3638446
Date : March 29 2020, 07:55 AM
I hope this helps . If this only applies to b nodes, then add a condition that the b node you match to must not have a b node above it with the same id:
code :
MATCH(a:`a thing`)
WITH a, a.resp_id as resp_id
MATCH (b:`b thing`) 
WHERE resp_id = b.item_id
AND NOT (:`b thing`{item_id:resp_id})-[:`has sub`]->(b)
MERGE (a)-[r:`Managed By`]->(b)
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org