##使用正则
/** * 3.2版本之前不支持full text search,只能这样正则模糊查找 * @param key * @return */ PagefindByContentLike(String key,Pageable pageable);
##使用full text search 3.2版本才支持中文
@Documentpublic class Article { @Id private String id; /** * 全文检索 */ @TextIndexed private String content; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getContent() { return content; } public void setContent(String content) { this.content = content; }}
###TextCriteria
PagefindBy(TextCriteria criteria, Pageable page);@Test public void testFullTextSearch(){ TextCriteria textCriteria = TextCriteria.forLanguage("hans") .matchingAny("技术"); Page page = articleDao.findBy(textCriteria,new PageRequest(0,10)); System.out.println(page.getTotalElements()); }