neo4j filter results from collect -


my problem this, have query one:

match (a:a), (a)-[:relation]-(b:b) return {name: a.name, products: collect(distinct {productname: b.name,  ident: b.identifier}) } 

and can't find way filter result of 'products', example, having rows productname = 'pname1' contained in array 'products':

row1: {name: 'name', products:[{name: 'pname1', ident: 'id1'}, {name: 'pname3', ident: 'id3'}] } row2: {name: 'name2', products:[{name: 'pname2', ident: 'id2'}] } 

the example above return row1

thank in advance attention

the with clause interesting thing query can splitted , query results @ point can saved variables.

so, first row, query

match (a:a), (a)-[:relation]-(b:b) a, collect(distinct {productname: b.name, ident: b.identifier}) products {productname: "pname1", ident:"id1"} in products return {name: a.name, products: products} 

edit:

the solution above compares whole map bit ugly if there more properties. compare productname query bit more tricky:

match (a:a), (a)-[:relation]-(b:b) a, collect(distinct {productname: b.name, ident: b.identifier}) products unwind products prows a, prows, products prows.productname = "pname1" return {name: a.name, products: products} 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -