Hi, Michael,
Michael McQuade wrote:
Quote:
Hi folks, it there anyone here, that is doing complex queries using the Full TEXT index features and BOOLEAN Searchs????
We are doing boolean queries against full text indexed columns, and this
|
is how we do it:
Having created an index on table song, fields "name" and "description",
the customers enter a search string, "query". If this is to be
boolean, you'll have to use "+" in front of words that logically
must be within the results (as with google searches) and a "-"
before words that shan't be within the result.
The code, then:
// First build up the query string for the full text condition:
String cond="MATCH (s.name, s.description) AGAINST ('"+
query+
"' IN BOOLEAN MODE) > 0.001";
(the MySQL syntax is:
MATCH (field1, field2) AGAINST ('seach phrase' IN BOOLEAN MODE)
Quote:
[decimal with acurracy, see reference] |
Then use it:
String sql = "SELECT s.name, s.price FROM stuff s WHERE " + cond;
ResultSet rs;
Statement stmt = Config.con.createStatement();
stmt.setEscapeProcessing(false);
rs = stmt.executeQuery(query);
etc etc
Naturally irl, you'll strip the query string from unwanted characters
first, and implement some kind of "next 15 matches" scheme.
You will also need to inform the users of the search thing how boolean
searches works. Example: all cars that have 4wd but are not Hondas:
"+car +4wd -honda"
As to your question of "complex" queries, you can have as complex
queries you'd like together with this feature, since it is a boolean
expression with the "greater than character". Just AND it to your
"complex" WHERE clause.
Quote:
Do you know if JDBC v 3.1.3-beta and MYSQL 4.1.3b-beta support this feature,
and does it work?????? Im desperate for answers, please email
|
me.....
Could you also send some sample code, if thats possible.... thank you
so much......
This has not so much to do with JDBC as with the engine itself imho.
Hope you can have any use of my example above.
Cheers
Rikard
--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe: http://lists.mysql.com/java?unsub=my...ie.nctu.edu.tw