[Zope-dev] Searching a relational database

Richard Taylor r.taylor@eris.dera.gov.uk
29 Jun 2000 15:00:56 +0100


James Henstridge <james@quoll.daa.com.au> writes:

> On Sat, 24 Jun 2000, Thomas Weholt wrote:
> 
> > Hi,
> >  
> > How can I search a relational database thru Zope? ( I`m using PostgreSQL
> > 7.0.2 on Linux ). I have a DVD/VHS-organizing project that would be
> > pretty useless if people couldn`t search for movies by entering just
> > parts of the title. 
> >  
> > Ex. typing alien should show "Alien" and "Alien 3". 
> 
> If you just want to do a single search term, you could easily set up an
> SQL method that read something like:
>   select * from table where title like '%<dtml-sqlvar search>%'
> 
> (I hope that syntax works with MS SQL server).  It is probably possible to
> get zope to escape special characters in the string for you as well.
> 

I use the regexp search option in Postgresql (~*) to do complex
searches. Unfortunately this means that your users will have to write
regular expressions. 

If anyone is interested in writing a booleans search syntax to regexp
converter I would be very interested.


> >  
> > Can ZCatalog be used for this? If I have a SQL-statement that returns
> > all rows in a database, can ZCatalog index this? 
> 
> This would negate the benefits of having an SQL database (eg. indexing,
> etc).  Just write an sql method that does the search.
> 
> >  
> > What I`m looking for is similar to full-text searching on MS SQL 7.0
> > etc.
> >  
> > Tips, hints or pointers??
> >  
> > Thomas
> >  
> 
> James.
> 

Richard