Forum OpenACS Q&A: tsearch2 vs fine grain search

Collapse
Posted by Roger Lockerbie on
Hello All

I integrated tsearch2 based searching into one of our custom packages the other day, using the search package and setting up service contracts for the package.

It all worked easy as pie.

But we want to be able to limit search results much more, for instance we have a newspaper classified advertising package (content repository based )and we wish to

* search only content that is of a classified_ad type
* optional search of only certain classifications
* optional search of a certain date/date range.

I decided to draw inspiration from forums search as that allowed search of only form messages and within actual individual forums.

But that searching is provided by a standard like clause within a sql query that is constructed from the relevant tables (i.e not using tsearch at all).

Looking at the tsearch2 driver it appears that you can pass a date range (although there are some dodgy comments in the code that imply something has been coded very roughly). And possibly limit results to a given package by passing the tsearch2::search routine a package_id.

Given that forums does not use tsearch2 I have the following questions

Is tsearch2-driver designed for site-wide only and should custom search routines be written for each package specific search-route ala forums

It appears as if it is the apps responsibility to package everything up for tsearch2-driver either as headline (to be displayed by search package txt (a coalesce of all searchable text) and keywords, that is easy enough but I am finding it difficult to work out how I can have a granular search based on the various acs tables that make up an object and also use tsearch2 data from the txt table.

In a nutshell I'm struggling to navigate the search package to work out how to create queries that combine full-text search with attributes from other tables.

Has anyone developed a more granular search for their package using a combination of tables and tsearch or openFTS.

Any pointers to accelerate my learning would be much appreciated (rollout pressure is about to ensue)...

Thanks

Collapse
Posted by Dave Bauer on
I developed some custom code that accepted keyword operators similar to Google,

so you could pass title:foo

and it would search in the title field for "foo" I added the code within the tsearch2-driver. I plan on generalizing this and adding it to openacs.org

I'd look into just using package_id search for now. I setup bugtracker search on openacs.org that way and it is very effective.