I just want to code a simple search engine using JPA. Here's example of native sql request that works with PHP :
"SELECT mobiles.brand, argus_waitings_mobiles_prices.mobile, argus_waitings_mobiles_prices.argus_buyer_id, "
. "MATCH(mobile) AGAINST('$mobile_tags' IN BOOLEAN MODE) AS pertinence "
. "FROM argus_waitings_mobiles_prices "
. "WHERE argus_waitings_mobiles_prices.argus_buyer_id = $buyerId "
. "ORDER BY pertinence DESC "
. "LIMIT 10");
I want to do the same like this but it does not work :
@Override
@SuppressWarnings("unchecked")
@Transactional(readOnly=true)
public List<Thread> findAllWithReferer(String referer) {
EntityManager entityManager = EntityManagerUtil.createEntityManagerAndOpenTransaction();
Query query = entityManager.createQuery("SELECT t "
+ "MATCH(t.title) AGAINST(:referer IN BOOLEAN MODE) AS pertinence "
+ "FROM Thread t MATCH(t.title) AGAINST(:referer IN BOOLEAN MODE)"
+ "ORDER BY pertinence DESC "
+ "LIMIT 10");
return (query.getResultList());
}
Here's the begin of the error message :
Caused by: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: MATCH near line 1, column 40 [SELECT t FROM fr.dorian.model.Thread t MATCH(t.title) AGAINST(:referer IN BOOLEAN MODE)]
Does anyone can help me, please?
Thanks in advance for your help.