@Query("MATCH (product:Product),\n" + "\t(product)<-[:PRODUCT_TYPE]-(inventory:Inventory)\n" + "WHERE product.productId in {productIds} AND NOT (inventory)<-[:CONTAINS_PRODUCT]-()\n" + "RETURN inventory") List<Inventory> getAvailableInventoryForProductList(@Param("productIds") String[] productIds); }
@Query("MATCH (product:Product),\n" + "\t(product)<-[:PRODUCT_TYPE]-(inventory:Inventory)\n" + "WHERE product.productId = {productId} AND NOT (inventory)<-[:CONTAINS_PRODUCT]-()\n" + "RETURN inventory") List<Inventory> getAvailableInventoryForProduct(@Param("productId") String productId);
@Query("MATCH (product:Product),\n" + "\t(product)<-[:PRODUCT_TYPE]-(inventory:Inventory),\n" + " (inventory)-[:STOCKED_IN]->(:Warehouse { name: \"{warehouseName}\" })\n" + "WHERE product.productId = {productId} AND NOT (inventory)<-[:CONTAINS_PRODUCT]-()\n" + "RETURN inventory") List<Inventory> getAvailableInventoryForProductAndWarehouse(@Param("productId") String productId, @Param("warehouseName") String warehouseName);
@Query(value = "START sourceContent=node({0}) MATCH sourceContent - [r:similarityRelation] - targetContent " + "WHERE r.strength > {1} AND r.type = {2} " + "RETURN r", countQuery = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "WHERE r.strength > {1} AND r.type = {2} " + "RETURN count(targetContent)") public Page<SimilarityRelation> getSimilarContents(ContentNode sourceNode, Double minimumStrength, String similarityType, Pageable pageable);
@Query("MATCH (user:User) WHERE has(user.pagerank) AND NOT has(user.screenName)\n" + "WITH user\n" + "ORDER BY user.pagerank DESC\n" + "LIMIT 1\n" + "RETURN user") User findRankedUserToCrawl();
@Query("START personNode=node({0}) " + "MATCH personNode <- [r:identityRelation] - identity " + "WHERE {1} in r.versions " + "WITH DISTINCT identity " + "OPTIONAL MATCH identity - [r:identityRelation] -> (p:personType) " + "WHERE NOT has(r.versions) " + "WITH DISTINCT identity, count(r) as count " + "WHERE count = 0 " + "MATCH identity <- [cr:contentContributionRelation] - content " + "WHERE content.status <> 'HIDDEN' " + "RETURN content.type as type, COUNT(DISTINCT content) as count") List<Map<String, Object>> countAuthorContributionsByType(PersonNode node, String version);
@Query( value = "MATCH (`user`)-[:`referredBy`]->(`user_referredBy`) " + "WHERE `user_referredBy`.`name` =~ {0} " + "RETURN `user`") Iterable<User> simulateFindByReferredByNameLikeWhenUsingLabelBasedStrategy(String name);
@Query( value = "MATCH (`user`:`User`) " + "WHERE `user`.`name` = {0} " + "RETURN `user`") Iterable<User> simulateFindByNameWhenUsingLabelBasedStrategy(String name);
/** * Initialize the user.lastPageRank value to the current user.pagerank */ @Query("MATCH (user:User) WHERE has(user.pagerank) AND has(user.screenName) AND NOT has(user.lastPageRank)\n" + "WITH collect(user) as users\n" + "FOREACH(x in users | \n" + "SET x.lastPageRank = toFloat(x.pagerank))") void setLastPageRank();
@Query("START contentNode=node({0}) " + "MATCH contentNode - [:contentContributionRelation] -> (idNode:identityType) " + "MATCH idNode - [idRel:identityRelation] -> (person:personType) " + "WHERE NOT has(idRel.versions) OR {1} in idRel.versions " + "RETURN DISTINCT person") Iterable<PersonNode> findContentPersons(ContentNode node, String version);
@Query(value = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] -> targetContent " + "WHERE r.type = {1} " + "RETURN r", countQuery = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] -> targetContent " + "WHERE r.type = {1} " + "RETURN count(targetContent)") public Page<SimilarityRelation> getSimilarContents(ContentNode sourceNode, String similarityType, Pageable pageable);
@Query(value = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "WHERE r.strength > {1}" + "RETURN r", countQuery = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "WHERE r.strength > {1}" + "RETURN count(targetContent)") public Page<SimilarityRelation> getSimilarContents(ContentNode sourceNode, Double minimumStrength, Pageable pageable);
@Query(value = "MATCH (cited:contentType) <- [c:citationRelation] - (target:citationType)" + " <- [ref:referenceRelation] - (source:contentType)" + " WHERE {0} in c.types" + " WITH cited, count(distinct source) as count" + " RETURN count, cited.id as id", countQuery="MATCH (cited:contentType) <- [c:citationRelation] - (target:citationType)" + " <- [ref:referenceRelation] - (source:contentType)" + " WHERE {0} in c.types" + " WITH cited, count(distinct source) as count" + " RETURN count(cited)", elementClass = Citation.class) public Page<Citation> getMostCitedPublications(String citationType, Pageable pageable);
@Query("START sourcePerson=node({0}) " + "MATCH sourcePerson -[toIdentity:identityRelation] - identity " + "MATCH identity -[toPerson:identityRelation] - targetPerson " + "WHERE {1} IN toPerson.versions " + "RETURN targetPerson LIMIT 1") PersonNode findCurrentPerson(PersonNode sourceNode, String requiredVersion);
@Query("START userNode=node({0}) " + "MATCH userNode <- [r:identityRelation] - identity " + "WHERE NOT has(r.versions) " + "MATCH identity <- [cr:contentContributionRelation] - content " + "WHERE content.status <> 'HIDDEN'" + "RETURN content.type as type, COUNT(DISTINCT content) as count") List<Map<String, Object>> countUserContributionsByType(UserNode node);
@Query(value = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "RETURN r", countQuery = "START sourceContent=node({0}) " + "MATCH sourceContent - [r:similarityRelation] - targetContent " + "RETURN count(targetContent)") public Page<SimilarityRelation> getSimilarContents(ContentNode sourceNode, Pageable pageable);
@Query("MATCH (a:User)<-[r:FOLLOWS]-(b)\n" + "WHERE NOT has(a.screenName)\n" + "WITH a, count(r) as weight\n" + "WHERE weight > 2\n" + "WITH a, weight\n" + "ORDER BY weight DESC\n" + "LIMIT 1\n" + "WITH a\n" + "RETURN a") User findNextUserToCrawl();
/** * Inventory到Product关系为:PRODUCT_TYPE * Shipment到Inventory关系为:CONTAINS_PRODUCT * @param productId * @return */ @Query("MATCH (product:Product)<-[:PRODUCT_TYPE]-(inventory:Inventory) WHERE product.productId = {productId} AND NOT (inventory)<-[:CONTAINS_PRODUCT]-() RETURN inventory") List<Inventory> getAvailableInventory(@Param("productId") String productId);
/** * Efficiently batches the creation of many FOLLOWS relationships * between {@link User} nodes * * @param follows a set of relationship entities containing a user "A" who follows a user "B" */ @Query("FOREACH(x in {follows} | MERGE (a:User { profileId: x.userA.profileId })\n" + "MERGE (b:User { profileId: x.userB.profileId })\n" + "MERGE (a)-[:FOLLOWS]->(b))") void saveFollows(@Param("follows") Set<Follows> follows); }
@Query("MATCH (user:User) WHERE has(user.pagerank) AND has(user.screenName) AND coalesce(user.imported, false) = true\n" + "WITH user\n" + "ORDER BY user.pagerank DESC\n" + "SKIP {skip}\n" + "LIMIT {limit}\n" + "RETURN user") Set<User> findRankedUsers(@Param("skip") Integer skip, @Param("limit") Integer limit);