Synonyms: how to match a list property?

I have a lot of nodes which have a name property.

The name is something comma separated, because it contains synonyms.

So, I decided to try to set the name as a list instead of a single string.

a specific query

match (n:AppellationNew {uuid: "c38e2d52-ebd0-48f3-80d4-e57635e36070"}) return n

returns the following value if shown as a Text, where the name is clearly a List:

{"name":["Asolo Montello","Montello Asolo","Montello","Colli Asolani"]│

But the same query, if shown as a graph, return a node with the following attributes:

**<id>:** 3526 **name:**Asolo Montello,Montello Asolo,Montello,Colli Asolani **uuid:** c38e2d52-ebd0-48f3-80d4-e57635e36070

Where the name is espressed as a single string with comma separated values.

The name property is indexed and unique with

create constraint on (n:AppellationNew) assert n.uuid is unique
create constraint on (n:AppellationNew) assert is unique

Now, if I try to query that node

match (n:AppellationNew ) WHERE CONTAINS "Asolo" return n

it returns nothing.

So, I have the following questions:

  1. How can I query to obtain the expected result?
  2. How can I query on a list property?
  3. How Neo4j indexes a property which is actually a list?

Thank you

Hello @p.dipietro :slight_smile:

If you only want to check one name:

MATCH (n:AppellationNew )
WHERE "Asolo" IN

If you want to check several names, have a look at predicate functions:

MATCH (n:AppellationNew )
WHERE all(name IN ["Asolo Montello", "Montello Asolo"] WHERE name IN

Can't help you for the question related to how lists are indexed.


1 Like

Hi @Cobra

Thank you for your answer. It solved a lot of problems.

But what if I want to use pattern matching?

Something like

MATCH (n:AppellationNew )
WHERE "Asolo" =~ '(?i)' + + '*.'

Do you think it would be possible'

Yes, it's possible, have a look at this topic.