Implement search filter for all columns

柔情痞子 提交于 2019-12-02 07:31:38

You will have to add your 'null guard' to the the fulltext search and use to_tsquery instead of plainto_tsquery (in order for prefix search to work).

SqlStatement = "SELECT * FROM ACCOUNT "
    + " WHERE (trim(?) = '') IS NOT FALSE"
    + " OR to_tsvector('english', USER_NAME || ' ' || FIRST_NAME || ' ' || LAST_NAME ) @@  to_tsquery(?)"
    + " ORDER BY user_name ASC offset ? limit ? ";

and add the searchString to your PreparedStatement a second time

 ps = conn.prepareStatement(sql);

 ps.setString(1, searchString);
 ps.setString(2, searchString);
 ps.setInt(3, firstRow);
 ps.setInt(4, rowCount);

Note using a fulltext search you will not be able to search for word-parts (like %user%, %name or us%name). You can search for prefixes though, e.g. user:*

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!