Dynamic queries

Hi guys i'm pretty new to neo4j and I have the following issue when using the neo4j driver:

Basically I want users to be able to filter certain nodes based on what they select on the Frontend i.e Node A WHERE A.price < £400.

My current attempy looks a bit like this. where I was hoping $filterQuery would return

'WHERE a.name IN ['citrus']'

self.session.run(
"MATCH (f:Fragrance)-[ha:HASACCORD]->(a:Accord) "
"$filterQuery "
"WITH f, ha, a "
"ORDER BY ha.strength DESC "
"RETURN f, collect({name: a.name, strength: ha.strength}) as accords",
filterQuery=get_fragrance_match_query(queries),
)

@emmanuelq38

parameterized queries are a great start. Is the query always restricting on price. If so why not

MATCH (f:Fragrance)-[ha:HASACCORD]->(a:Accord) "
"where a.price < $filterCriteria "
"WITH f, ha, a "
"ORDER BY ha.strength DESC "
"RETURN f, collect({name: a.name, strength: ha.strength}) as accords

Hi Dana thanks for your reply!

No there isn't a restriction a.price so the issue with parameterised queries here is that the query itself needs to be changeable as different users will want to query different things such as price, category, location etc eg

User A will want where a.price < $filterCriteria
But
User B will want where a.price < $filterCriteria1 AND where a.category IN $filterCriteria2

I want to essentially be able to optionally compound various where clauses depending on what a user selects.

@emmanuelq38

ok. perhaps your application can build the where clause. presumably your app has some ability to specify what fields are to be restricted upon and their value. using the values the user has choose should then be used to build the WHERE clause