I found this search example in PostgreSQL http://www.postgresql.org/docs/current/interactive/textsearch-tables.html#TEXTSEARCH-TABLES-SEARCH
I tried to implement this co
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:*