We have to carefully convert the user's query input to the boolean lexeme language TO_TSQUERY() expects. We may ultimately have to do more complicated things here, too.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2191 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -49,6 +49,7 @@ import com.samskivert.jdbc.depot.FieldMarshaller.ObjectMarshaller;
|
||||
import com.samskivert.jdbc.depot.FieldMarshaller.ShortMarshaller;
|
||||
import com.samskivert.jdbc.depot.annotation.FullTextIndex;
|
||||
import com.samskivert.jdbc.depot.operator.Conditionals.FullTextMatch;
|
||||
import com.samskivert.util.StringUtil;
|
||||
|
||||
import com.samskivert.Log;
|
||||
|
||||
@@ -97,7 +98,15 @@ public class PostgreSQLBuilder
|
||||
public void visit (FullTextMatch match)
|
||||
throws Exception
|
||||
{
|
||||
_stmt.setString(_argIdx ++, match.getQuery());
|
||||
// The tsearch2 engine takes queries on the form
|
||||
// (foo&bar)|goop
|
||||
// so in this first simple implementation, we just take the user query, chop it into
|
||||
// words by space/punctuation and 'or' those together like so:
|
||||
// 'ho! who goes there?' -> 'ho|who|goes|there'
|
||||
|
||||
String[] searchTerms = match.getQuery().toLowerCase().split("\\W+");
|
||||
String query = StringUtil.join(searchTerms, "|");
|
||||
_stmt.setString(_argIdx ++, query);
|
||||
}
|
||||
|
||||
protected PGBindVisitor (DepotTypes types, PreparedStatement stmt)
|
||||
|
||||
Reference in New Issue
Block a user