admin管理员组文章数量:1355202
I’m working on a Spring Boot 3.2 + Hibernate 6.6.11 + QueryDSL 5 project, using MySQL and attempting to implement full-text search using MATCH ... AGAINST (with ngram parser).
I have already created the full-text index in MySQL:
ALTER TABLE stores ADD FULLTEXT INDEX ft_store_name (name) WITH PARSER ngram;
In my repository, I tried to use QueryDSL
like this:
import static com.querydsl.core.types.dsl.Expressions.stringTemplate;
BooleanBuilder builder = new BooleanBuilder();
if (name != null && !name.isEmpty()) {
builder.and(
stringTemplate(
"MATCH({0}) AGAINST ({1} IN NATURAL LANGUAGE MODE)",
store.name, name
).isNotNull()
);
}
However, I get this error:
.hibernate.query.SyntaxException: At 3:24 and token 'AGAINST', mismatched input 'AGAINST', expecting one of the following tokens...
Root cause: As far as I understand, MATCH ... AGAINST is not valid JPQL, so Hibernate fails when trying to parse it.
I want to keep using QueryDSL and avoid using full native SQL if possible.
How can I use MATCH ... AGAINST in Hibernate 6 with QueryDSL?
本文标签: mysqlHow to use MATCHAGAINST (FullText Search) with Hibernate 6 and QueryDSLStack Overflow
版权声明:本文标题:mysql - How to use MATCH ... AGAINST (FullText Search) with Hibernate 6 and QueryDSL? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744036422a2579853.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论