I am using spring-neo4j. I have an entity called User with properties (username, firstName, lastName) and firstName and lastName are optional properties.
Now I want to implement a user search query which will search across all three properties.
@Query(value = "start user=node:__types__(className='com.xxx.entity.User') where user.username =~ {0} or user.firstName =~ {0} or user.lastName =~ {0} return user")
List<User> searchByName(String keyword);
The query fails saying that:
The property 'firstName' does not exist on Node[21].
However, if I search only on username, it gives me the result. I tried using the ? operator for nullable properties:
@Query(value = "start user=node:__types__(className='com.xxx.entity.User') where user.username =~ {0} or user.firstName? =~ {0} or user.lastName? =~ {0} return user")
List<User> searchByName(String keyword);
But this will fetch me all the nodes where firstName or lastName are missing.
Any idea how do I implement this query?