Skip to content

Instantly share code, notes, and snippets.

@Iknewthisguy
Created September 18, 2012 15:35
Show Gist options
  • Save Iknewthisguy/3743800 to your computer and use it in GitHub Desktop.
Save Iknewthisguy/3743800 to your computer and use it in GitHub Desktop.
Filter in Cypher
def match
criteria_matched = params[:quantity]
case criteria_matched
when criteria_matched == 4
results = Neo4j._query("START n=node(13626) MATCH(n)-[:_all]->(x) WHERE x.city == #{Resume.city} AND x.school == #{Resume.school} AND x.sport == #{Resume.sport} AND x.skill =~ /(?i-mx:.*#{Resume.skill}.*)/ RETURN x")
when criteria_matched == 5
results = Neo4j._query("START n=node(13626) MATCH(n)-[:_all]->(x) WHERE x.city == #{Resume.city} AND x.school == #{Resume.school} AND x.sport == #{Resume.sport} AND x.skill =~ /(?i-mx:.*#{Resume.skill}.*)/ AND x.history == #{Resume.history} RETURN x")
when criteria_matched == 6
results = Neo4j._query("START n=node(13626) MATCH(n)-[:_all]->(x) WHERE x.city == #{Resume.city} AND x.school == #{Resume.school} AND x.sport == #{Resume.sport} AND x.skill =~ /(?i-mx:.*#{Resume.skill}.*)/ AND x.history == #{Resume.history} AND x.pets == #{Resume.pets} RETURN x")
when criteria_matched == 7
results = Neo4j._query("START n=node(13626) MATCH(n)-[:_all]->(x) WHERE x.city == #{Resume.city} AND x.school == #{Resume.school} AND x.sport == #{Resume.sport} AND x.skill =~ /(?i-mx:.*#{Resume.skill}.*)/ AND x.history == #{Resume.history} AND x.pets == #{Resume.pets} AND x.mom == #{Resume.mom} RETURN x")
end
return results
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment