IgnoreCase Finder Not Working with Spring Data Rest and Neo4J
IgnoreCase Finder Not Working with Spring Data Rest and Neo4J
I am unable to coax Spring Data Neo4J (with Spring Data Rest) to ignore case with a finder method. Here's an example repository:
@RepositoryRestResource
public interface WidgetRepository extends PagingAndSortingRepository<Widget, Long> {
Optional<Widget> findByNameIgnoreCase(String name);
}
This example will only find widgets by exact case even though I have the IgnoreCase keyword. I would appreciate advice on how to get a finder method to ignore case with Neo4J. Thanks!
IgnoreCase
1 Answer
1
The case specific keywords are not implemented in Spring Data Neo4j yet. But it is possible to use regex in a derived query method.
Define a regex finder method
Optional<Widget> findByNameMatchesRegex(String name);
Optional<Widget> findByNameMatchesRegex(String name);
and use it like this
widgetRepository.findByNameMatchesRegex("(?i)paul");
widgetRepository.findByNameMatchesRegex("(?i)paul");
This is the only option right now within Neo4j to find strings by case-insensitive queries. https://neo4j.com/docs/developer-manual/current/cypher/clauses/where/#case-insensitive-regular-expressions
However this might be useful to support the ignoreCase keyword within Spring Data Neo4j as a convenient access function.
ignoreCase
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.