如何使用spring数据neo4j搜索全文
我正在学习spring数据neo4j和spring。我想搜索全文,例如我有三部电影sky,sky1,sky2,当我搜索sky时,它返回sky,sky1,sky2。我首先使用下面的存储库如何使用spring数据neo4j搜索全文,spring,spring-mvc,neo4j,spring-data-neo4j,Spring,Spring Mvc,Neo4j,Spring Data Neo4j,我正在学习spring数据neo4j和spring。我想搜索全文,例如我有三部电影sky,sky1,sky2,当我搜索sky时,它返回sky,sky1,sky2。我首先使用下面的存储库 package com.oberon.fm.repository; @Repository public interface MovieRepository extends GraphRepository<Movie> { Movie findById(String id);
package com.oberon.fm.repository;
@Repository
public interface MovieRepository extends GraphRepository<Movie> {
Movie findById(String id);
Page<Movie> findByTitleLike(String title, Pageable page);
}
下面是我的控制器
@RequestMapping(value = "/movies", method = RequestMethod.GET, headers = "Accept=text/html")
public String findMovies(Model model, @RequestParam("q") String query) {
log.debug("1");
if (query != null && !query.isEmpty()) {
Page<Movie> movies =movieRepository.findByTitleLike(query, new PageRequest(0, 20));
model.addAttribute("movies", movies.getContent());
} else {
model.addAttribute("movies", Collections.emptyList());
}
model.addAttribute("query", query);
addUser(model);
return "/movies/list";
}
这些不好用,我想可能是哪里出了问题,但我不知道,如果你有任何想法,告诉我谢谢!顺便说一下,它抛出异常java.lang.NullPointerException。
我的电影实体
@NodeEntity
public class Movie {
@GraphId
Long nodeId;
@Indexed(indexType = IndexType.FULLTEXT, indexName = "id")
String id;
@Indexed(indexType = IndexType.FULLTEXT, indexName = "search")
String title;
String description;
@RelatedTo(type = "DIRECTED", direction = INCOMING)
Set<Director> directors;
@RelatedTo(type = "ACTS_IN", direction = INCOMING)
Set<Actor> actors;
@RelatedToVia(type = "ACTS_IN", direction = INCOMING)
Iterable<Role> roles;
@RelatedToVia(type = "RATED", direction = INCOMING)
@Fetch
Iterable<Rating> ratings;
private String language;
private String imdbId;
private String tagline;
private Date releaseDate;
private Integer runtime;
private String homepage;
private String trailer;
private String genre;
private String studio;
private Integer version;
private Date lastModified;
private String imageUrl;
分享一个例外,你的电影是什么样子的?您的查询值是什么样子的?你应该在标题上使用@Indexedtype=fulltext。查询值是sky,我有三部电影sky,sky1,sky2,当我查询sky时,它返回sky,sky1,sky2,我是否丢失了任何东西,是否需要密码?这些都是我的代码。我不知道如何搜索db,只使用PageFindBytletleLike标题,Pageable页面;告诉我,迈克尔,非常感谢