[Zope] A ZSQL Method to do it like Google?

Neil Burnett neil@efc.be
Mon, 11 Feb 2002 13:37:16 +0100


Dear Zopers

I wonder if anyone has a ZSQL Method that will take a single text string,
parse it for 'AND' and 'OR' then create the appropriate sql statement.

A very simple example could be like this:

user enters 'dog AND biscuit'

SQL statement created is like:

SELECT * FROM TABLE1
WHERE (FIELD1 LIKE '%dog%'
AND FIELD1 LIKE '%biscuit%')
OR (FIELD2 LIKE '%dog%'
AND FIELD2 LIKE '%biscuit%')

Yes, I know that I can do the above very simply, but how about when the
string contains multiple sections with AND, OR, NEAR, NOT?

I think its difficult, so I am hoping someone else has already done it! A
quick search on the lists hasn't revealed anything obvious.

Regards

Neil