我想用密码搜索,
- 我有四个电影能量,阿甘,天空,天空1,天空2
- 我要搜索天空
- 我想要它返回天空,天空1,天空2
我的密码是
@Query("MATCH (movie:Movie) WHERE movie.title =~ '.*{0}.*' RETURN movie")
或者
@Query("MATCH (movie:Movie) WHERE movie.title =~ '(?i).*{0}.*' RETURN movie")
这些都不好用:无论我搜索什么(forrest 或 sky),它都会返回 forrest、sky、sky1、sky2。怎么了?控制器
@RequestMapping(value = "/movies", method = RequestMethod.GET, headers = "Accept=text/html")
public String findMovies(Model model, @RequestParam("q") String query) {
if (query != null && !query.isEmpty()) {
List<Movie> movies = movieRepository.findByTitleLike("(?i).*sky.*");
model.addAttribute("movies", IteratorUtil.asCollection(movies));
} else {
model.addAttribute("movies", Collections.emptyList());
}
model.addAttribute("query", query);
return "movies/list";
}