I have been experimenting with extending search to allow searching of additional properties in addition to the main full text index. I took some ideas from the more common search interfaces on the internet. Most use some sort of keyword to specify what element to search within.
For example, to search a page title one would enter a query like this: "title: apple".
So the solution I came up with was to parse out these keywords and generate fragments of a SQL query. This way, the search service contact was not changed, but a more complex search is allowed.
For one implementation I needed to restrict search within a .LRN course, I added a community_id keyword that passed in the community_id of the course. I think this would work well to enable subsite, or package_id restricted search based on OpenACS 5.2. This is because OpenACS 5.2 will have package_id within the acs_objects table, so a simple join would work.
I imagine this could be used to specify a category name or id to combine full text searching with the categories package.
It would also be possible to restrict search by object type.
Right now all these additions are in custom code. I added them straight into the tsearch2-driver, but I think really the should end up in the search package, so that any driver could take advantage of the features.
Also all the keyword query fragments are embeeded right in the tsearch2-driver in my experimental code. I think a tcl proc callback to generate the query would be best.
Something like search::${keyword}::query_fragment $query should workd. It would accept the part of the search query that corresponds to the keyword and would return a SQL query fragment and a join specification that could be added to the query. For example I might call search::package_id::query [list 1 2 3 4 5] which would return {{ o.package_id in (1,2,3,4,5)} {acs_objects o}} where the first part would be added to the where clause and the second part would be added to the list of tables to join on.
---
In addition to the keyword based extension to search additional properties I have also added AND, OR, and NOT boolean expressions to the tsearch2-driver. This code is available on OpenACS CVS HEAD.
Comments on how to move forward with this are welcome.