How to use MySQL's full text search from JPA

前端 未结 7 1851
谎友^
谎友^ 2020-12-15 13:55

I want to use MySQL\'s full text search features using JPA, without having to use a native query.

I am using EclipseLink, which has a function to support native SQL

相关标签:
7条回答
  • 2020-12-15 14:42

    What about new SQL operator in EclipseLink 4.0? I think it can help you to do fulltext search from JPQL. But you have to upgrade to EclipseLink 4.0.

    http://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Support_for_Native_Database_Functions#SQL

    Edit:
    Sorry for late update.
    Verified correct use of EclispeLink 2.4.0 "SQL" operator with MySQL fulltext search is

    SELECT person FROM People person WHERE SQL('MATCH(name) AGAINST( ? )', :searchTerm)"
    

    where name is column on which Fulltext index is defined. :searchTerm is string you use for searching.
    Works without problems.

    0 讨论(0)
提交回复
热议问题