Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-28-2022 05:09 AM
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.
04-28-2022 05:24 AM
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
04-28-2022 07:32 AM
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)
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.
04-28-2022 08:28 AM
You can use this query:
MATCH (n:Question)
WHERE n.Gender =~ "(?i).*male.*"
RETURN n
04-28-2022 09:34 AM
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".
04-28-2022 09:43 AM
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.
04-28-2022 11:27 AM
Yeah, even I have planned the same, replacing it with F and M. Well thanks anyways.
04-28-2022 11:38 AM
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
04-28-2022 07:31 PM
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.
04-28-2022 09:37 PM
If Gender property is used as list then one should use:
where 'Male' or 'Female' in a.Gender
All the sessions of the conference are now available online