Querying nodes using array property - neo4j

57 Views Asked by At

I have a property on the node which is stored as array of strings. But when I use this field to find the node, it's not returning any results. What am I doing wrong?

Below is the node:

MATCH (n:Product)
WHERE
n.id_product = 8
RETURN
n.keyterms

Result

["financial tool", "personal finance"]

I am trying to find the same node as above using the keyterms field:

MATCH (n:Product)
WHERE
["financial tool"] in n.keyterms
RETURN
n.keyterms

no records
1

There are 1 best solutions below

1
On BEST ANSWER

You don't have to put "financial tool", in an array, simply try this:

MATCH (n:Product)
WHERE "financial tool" in n.keyterms
RETURN n.keyterms

To search for, multiple values, you can do the following:

MATCH (n:Product)
WHERE ANY (key IN n.keyterms WHERE key IN ['financial tool', 'personal finance'] )
RETURN n.keyterms