Author | Message |
---|---|
talisunep
Posts: 140
|
Posted 23:10 Jun 04, 2013 |
professor to implement the fts queries in my controller since the results have 3 entities as in rank/title/description will i need to use an object to store the results in contoller to be passed to my jsp? |
cysun
Posts: 2935
|
Posted 23:25 Jun 04, 2013 |
You can use Review objects to hold the search results. |
talisunep
Posts: 140
|
Posted 23:30 Jun 04, 2013 |
Professor i am getting this error
SEVERE: Servlet.service() for servlet [bvvo] in context with path [/bvvo] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet] with root cause
org.postgresql.util.PSQLException: ERROR: syntax error at or near "@@"
Position: 175
im wondering if im doing my query right in the controller
String sql = "select ts_rank ( tsv, plainto_tsquery(:searchByReview)) as ranking ," + List <Review> searchedReviews = entityManager.createNativeQuery(sql, Review.class).setParameter("searchByReview", searchByReview).getResultList();
|
talisunep
Posts: 140
|
Posted 04:49 Jun 05, 2013 |
sorry my debugged my query had some syntax errors, its fixed now... Last edited by talisunep at
04:50 Jun 05, 2013.
|
cysun
Posts: 2935
|
Posted 07:23 Jun 05, 2013 |
In the JSP showing the search results, you don't really need the original review title or content, just the title and content with the search terms highlighted, so you can do something like: select id, ts_headline(title, ...) as title, ts_headline(content, ...) as content from ... This way the title and content fields of the Review objects will hold the highlighted title and content instead of the original ones. |