cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

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.

9 REPLIES 9

Hello @vence.andersen17

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

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)
3X_d_e_de1dfca2da4b7d1e9dea5770e6c92788e2efa504.png
3X_c_3_c32ee6718235d9df4b46a2b45d812af2a6497403.png
3X_a_6_a617da980494cb61f3bb230d4b75b367815d0beb.png

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

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
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.

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

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