Return nodes with Partial match

There are nodes with 3 different types of Properties, "Male", "Female", "Male, Female". When query something like "match (n:label) where "Male" in n.Gender return n" can I get nodes with Properties having "Male" and "Male, Female" as the query gives nodes with "Male" as the property.

Thanks in advance.

Hello @vence_andersen1 :slight_smile:

I don't understand what is the issue with your query. Can you give an example of what you would like to get?

Regards,
Cobra

1 Like

Sorry, I'm re-framing the question.

Well the nodes has a property called "Gender" that could have 3 different values "Male", "Female", "Male,Female"(I'm attaching few example images below)
image
image
image

Is it possible to query the nodes which are having Gender property as "Male" and "Male,Female", I don't want nodes having the Gender property as Female.

You can use this query:

MATCH (n:Question) 
WHERE n.Gender =~ "(?i).*male.*" 
RETURN n
1 Like

Thanks for the reply well the word "female" has the word "male" in it so I'm getting all the nodes, like nodes having their Gender property as "Male", "Female","Male,Female".

Oh yeah true, my bad :slight_smile:
I don't see a good way of doing it with these valued, is it possible to replace female gender by F the male value by M? It will be easier.

1 Like

Yeah, even I have planned the same, replacing it with F and M. Well thanks anyways.

Try this:
MATCH (a) where a.Gender contains("Male")
should return nodes with ids: 528 and 546

MATCH (a) where a.Gender contains("Female")
should return nodes with ids: 540 and 546
1 Like

You could also set the Gender property to a list, instead of the concatenation of the two genders. Then you can use list predicates, such as "Male" in a.Gender or not "Male" in a.Gender. If you want the nodes that contain both, you can use size(a.Gender) = 2.

If Gender property is used as list then one should use:
where 'Male'  or 'Female' in a.Gender
1 Like